skmonir's blog

By skmonir, history, 6 years ago, In English

Given two integers a and b (1 <= a, b <= 1e5). m = 1e9 + 7.

There will be up to 1e5 steps. In each step-
1. Two integers t (1 <= t <= 2) and c (1 <= c <= 1e5) are given. If t = 1, multiply a by c. Else if t = 2, multiply b by c.
2. Find the value of (a % b) % m.

Note that, a or b may be changed after each step.

btw, it's not any OJ problem. I'm just interested about the solution.

  • Vote: I like it
  • +14
  • Vote: I do not like it

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

if a =3 b = 4 no of step =1 ans= (3%4)%m; if no step = 2 .there is no change ? i can do the same thing or in each step you give a and b then we can do the same thing. if you want to maximize or minimize things then its an another issue.

sorry if i guess wrong. better you can clarify the problem more

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Blog is updated. Hope now u can understand.