Difference between %I64d %lld

Many of my submissions resulted in WA when i used %I64d rather got AC when i used cin for scanning them , anyone tell me the difference .
Even many solutions got TLE when i used cin , got AC by scanf.

This is really annoying.

Can sometime tell me a better way of handling.

1 Like

It depends on the compiler. Some, like the usual MinGW or Codeforces’ G++, use the %I64d specifier for “long long”, and when encountering the %lld one, they just consider it an int. Vice versa on Linux G++ compilers. And if you read a large long long as an int, it turns out to be something random in the variable. That’s why you’re getting WA.

If your cin is too slow, try starting your main() function with cin.sync_with_stdio(0);.

3 Likes