Codeforces 1328A Problem

I have been solving Codeforces easy problems, i have stuck somewhere in segmentation fault,
question link - https://codeforces.com/problemset/problem/1328/A
code link - https://ide.codingblocks.com/s/225526

plz check and help ,where im getting this wrong

hello @akb.tech17
you solution complexity O(t*b) when t can be upto 10^4,a and b can upto 10^9.

in worst case this will fail to get answer on time.
refer this->https://ide.codingblocks.com/s/225589

so how can i optimize

use math,
if a>=b .
… if(a%b==0) then answer will be zero.
… otherwise find multiple of b which is just greater than a ,and answer will be anew-a.

else
… b-a

recursive approach or simple algo?

simple algo . . . . . .

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.