TLE problem with O(1) time complexity solution

This is my solution -


[1] for the problem [TR][2] of contest Encoding Feb'19
the solution is giving  TLE verdict for O(1) complexity and O(T) total complexity.
can anyone tell me the reason?
Thank you!


  [1]: https://www.codechef.com/viewsolution/23273030
  [2]: https://www.codechef.com/ENFE2019/problems/TR

The range of test cases is from 1 to 10^9! It’s almost impossible to scan that much and give output in 1 second.

But in this case you just have use fast i/o to take the input. This worked in my case.

what is faster than scanf and prinf in c, c++?

You could use this simple fast i/o template using cin and cout. See my code for an example https://www.codechef.com/viewsolution/23279921

#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
//