# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
319149 | sofapuden | Odd-even (IZhO11_oddeven) | C++14 | 1022 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
string add(string a, string b){
string c;
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
while(a.size() < b.size()){
a+='0';
}
while(b.size() < a.size()){
b+='0';
}
int last = 0;
for(int i = 0; i < (int)a.size(); ++i){
int cur = a[i]+b[i]-2*'0' + last;
last = cur/10;
c+=(char)('0'+cur%10);
}
if(last){
c+=(char)('0'+last);
}
reverse(c.begin(),c.end());
return c;
}
string subs(string a, string b){
string c;
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
while(b.size() < a.size()){
b+='0';
}
int last = 0;
for(int i = 0; i < (int)a.size(); ++i){
int cur = a[i]-b[i] + last;
last = (cur-10)/10;
c+=(char)('0'+((cur+10)%10));
}
while(c.back() == '0')c.pop_back();
reverse(c.begin(),c.end());
return c;
}
bool gre(string a, string b){
if(a.size() > b.size()){
return true;
}
if(b.size() > a.size()){
return false;
}
return a >= b;
}
int main(){
string a; cin >> a;
string cn = "1";
string cur = "1";
while(!gre(cur,a)){
cn = add(cn,"1");
cur = add(cur,cn);
}
cout << subs(add(a,a),cn);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |