This is with regards to Codeforces question - 1352A Sum of Round Numbers. When I compiled the following code on the website using compiler GNU G++17 7.3.0
I successfully got the desired result, for example, with the test case 9878
my code gave the correct output viz. 6 70 800 9000
however when I compiled the same code using GNU G++11 5.1.0
I got an output 6 70 799 9000
. Can someone please explain the reason behind 799
?
#include <bits/stdc++.h>
using namespace std;
int main(){
int n, num, len, count=0;
// string num_str;
cin>>n;
for(int i=0; i<n; i++){
count=0;
vector<int> vec;
cin>>num;
len = to_string(num).length();
for(int i=len-1; i>-1; i--){
if(num%10 == 0){
num = num/10;
}
else{
// count++;
vec.push_back((num%10)*pow(10,count));
num /=10;
}
count++;
}
cout<<"\n"<<vec.size()<<"\n";
for(auto j=vec.begin(); j!=vec.end(); ++j){
cout<<" "<<*j<<" ";
}
}
}
Here's the link referencing my code - link. Thanks!