I cannot find the difference between the solution and my program.
solution: CodeChef: Practical coding for everyone
my program: CodeChef: Practical coding for everyone
There is literally no difference between these two program. Runs correctly on my VSCode, yet one is running successfully and the other one just doesn’t budge.
ssjgz
October 24, 2021, 7:38pm
2
The one with WA has:
printf("%11d\n", sum);
The 11
should be ll
, as it is in the AC solution.
Edit:
[simon@simon-laptop][20:42:41]
[~/devel/hackerrank/otherpeoples]>diff -w sahithi_gsl-ODDSUM.cpp siddhanta1012-ODDSUM.cpp
15c15
< printf("%lld\n", sum);
---
> printf("%11d\n", sum);
21d20
<
Edit2:
Another hint is the compiler warning that is only present for one of the two:
[simon@simon-laptop][20:49:23]
[~/devel/hackerrank/otherpeoples]>./compile-latest-cpp.sh
Compiling siddhanta1012-ODDSUM.cpp
Executing command:
g++ -std=c++17 siddhanta1012-ODDSUM.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_GLIBCXX_DEBUG -fsanitize=undefined -ftrapv
siddhanta1012-ODDSUM.cpp: In function ‘int main()’:
siddhanta1012-ODDSUM.cpp:15:33: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
printf("%11d\n", sum);
^
siddhanta1012-ODDSUM.cpp:5:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &t);
~~~~~^~~~~~~~~~~~
siddhanta1012-ODDSUM.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &n);
~~~~~^~~~~~~~~~~~
Successful