lucky1740's blog

By lucky1740, history, 8 years ago, In English

I am getting Different answers on my PC(g++ (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609 compiler) and the compilers on CodeForces such as G++ 11,G++ 14, G++ 17 for the Problem 1060B. The output on MY PC is 91 for input (10000000000) and the output on G++ 17,G++ 14, G++ 11 is 82 for the same input. I am Attaching two screenshots . First One is of MY PC and the other is of G++ 17 compiler on CodeForces. Should I use a differnet compiler for c++ programs on CodeForces ? Please help me through this. Link for first image: /predownloaded/55/7d/557de76deecb86d12ca5e0e6ebbfcbe7402264f6.jpg Link for second image: /predownloaded/b1/0e/b10e376600e2f8dc1b7faab67874bb0fe34fa09f.jpg

  • Vote: I like it
  • -6
  • Vote: I do not like it

| Write comment?
»
8 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

In your submission here, input is overflowing the value of n. Output divergence is caused by the difference in compilers.

Output of -

cout<<"SizeOfLong    : "<<sizeof(long)<<endl;
cout<<"SizeOfLongLong: "<<sizeof(long long)<<endl;

On codeforces:

SizeOfLong    : 4
SizeOfLongLong: 8

On my PC/probably in yours too:

SizeOfLong    : 8
SizeOfLongLong: 8

You can try using long long for 8-byte integer.