Question

In: Computer Science

Please answer in C++ Given 3 numbers T, r and s, where r != s and...

Please answer in C++

Given 3 numbers T, r and s, where r != s and r > 1 & s > 1. Print a list of numbers from 1 to T where numbers divisible by r whose decimal representation does not contain the digit r should be replaced by the number 555 and any number (int) divisible by s whose decimal representation does not contain the number s should be replaced by the number 333. Numbers for which both of the past arguments are true should be replaced by the number 444.

Input

7 2 3

Expected Output

1 2 3 555 5 444 7

Solutions

Expert Solution

CODE:

#include<bits/stdc++.h>
using namespace std;

int main() {
        int t,r,s,i = 1;
        cin >> t >> r >> s;
        while(i <= t) {
                if(i%s == 0 && i%r == 0){
                        cout << 444 << " ";
                }else if(i%s == 0 && i != s) {
                        cout << 333 << " ";
                }else if(i%r == 0 && i != r) {
                        cout << 555 << " ";
                }else {
                        cout << i << " ";
                }
                i++;
        }
        cout << endl;
        return 0;
}


Related Solutions

The acceleration of a bus is given by a(t) = at, where a =1.2m/s^3. a) If...
The acceleration of a bus is given by a(t) = at, where a =1.2m/s^3. a) If the bus's velocity at time t = 1.0s is 5.0m/s, what is its velocity at time t = 2.0s ? b) If the bus's position at time t= 1.0s is 6.0m, what is its position at time t = 2.0s? c) Sketch ay -t, vy -t, and x -t graphs for the motion.
Let L = {x = a r b s c t | r + s =...
Let L = {x = a r b s c t | r + s = t, r, s, t ≥ 0}. Give the simplest proof you can that L is not regular using the pumping lemma.
Indicate the net charge for the peptide, C-H-A-V-E-C-A-R-R-I-S-T-H-E-G-R-E-A-T-E-S-T, at the given pH values: (a) pH 1,...
Indicate the net charge for the peptide, C-H-A-V-E-C-A-R-R-I-S-T-H-E-G-R-E-A-T-E-S-T, at the given pH values: (a) pH 1, net charge: (b) pH 5, net charge: (c) pH 8, net charge: (d) pH 14, net charge:
The curve C is given by the parameterization ⃗r(t) = <−t , 1 − t^2> for...
The curve C is given by the parameterization ⃗r(t) = <−t , 1 − t^2> for −1 ≤ t ≤ 1. a) Choose any vector field F⃗ (x, y) = 〈some function , some other function〉 and setup the work integral of F⃗ over C. b)Choose any vector field G⃗(x,y) which has a potential function of the form φ(x,y)= x^3 + y^3 + some other stuff and compute the work done by G⃗ over C. Please use a somewhat basic...
The forward price of a currency is given by f(S, t) = S e^(r−rf ) (T...
The forward price of a currency is given by f(S, t) = S e^(r−rf ) (T −t) , a) Show that if f(S, t) < S e(r−rf ) (T −t) , then arbitrage profits can be made. Hint: because f(S, t) is “too low” and S is “too high,” today’s arbitrage trades are i) Enter a long position in the forward contract. (That is, agree to buy the foreign currency at time T at the price f(S, t) per unit...
Evaluate the line integral ∫CF⋅d r where F=〈4sinx,cosy,xz〉 and C is the path given by r(t)=(t^3,3t^2,3t)...
Evaluate the line integral ∫CF⋅d r where F=〈4sinx,cosy,xz〉 and C is the path given by r(t)=(t^3,3t^2,3t) for 0≤t≤1 ∫CF⋅d r=
Given: C = $4.00, P = $6.00, S = $42, K = $45, T = 3...
Given: C = $4.00, P = $6.00, S = $42, K = $45, T = 3 months, r = 8%. The option contracts are written on 100 units of the underlying asset. (Show work.) What would you do to exploit these quotes? (List all transactions you would make.) What would be your riskless profit? How could you synthetically sell a call option? What would be the cash flow from doing this? (i.e., What is the synthetic call premium?)
(a) Find R+S+T. Draw the arrows to show the answer.
(a) Find R+S+T. Draw the arrows to show the answer.(b) Find R+S+T, where R= (2, 4), S= (6,5), T= (8,-3)(d) Discuss three (3) examples or scalar and vector. (6 marks)
Given the following economy: Y = C(Y - T) + I(r) + G C(Y - T)...
Given the following economy: Y = C(Y - T) + I(r) + G C(Y - T) = a + b(Y - T) I(r) = c - dr M/P = L(r,Y) L(r,Y) = eY - fr i. Solve for Y as a function of r, the exogenous variables G and T, and the model's parameters a, b, c, and d. ii. Solve for r as a function of Y, M, P, and the parameters e and f. iii. Derive the aggregate...
Consider the vector function given below. r(t) = 2t, 3 cos(t), 3 sin(t) (a) Find the...
Consider the vector function given below. r(t) = 2t, 3 cos(t), 3 sin(t) (a) Find the unit tangent and unit normal vectors T(t) and N(t). T(t)   =    N(t)   =    (b) Use this formula to find the curvature. κ(t) =
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT