### Saratov State University :: Online Contester

::Go
- home
- news
- register
 - update personal info
 - problemset archive
- submit
- status online
- standing
- contests
- virtual contests
- forum
- statistic
- FAQ
- projects

 ::Poll Are you registered on Codeforces?YesNoWhat is it???[results]

::webboard

Author: SamiraG
ID: 055799
Problem: 193
Contest: 0
Date: 2014-11-26 13:08:29

the judge of the problem 193 is not correct
because once i submitted a wrong program which was accepted
this program gives wrong answer for input 1000 for example.

this is the code, check if needed:

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

struct BNum
{
vector <int> num;
BNum(string s = "")
{
for (int i = s.size() - 1; i >= 0; i--)
num.push_back(s[i] - '0');
}
void output()
{
for (int i = num.size() - 1; i >= 0; i--)
cout << num[i];
cout << endl;
}
void clear0()
{
while(num.size() > 1 && num.back() == 0)
num.pop_back();
}
void m1()
{
if (num[0])
num[0]--;
else
{
num[0] += 9;
num[1]--;
}
}
void div2()
{
bool a = false;
for (int i = num.size() - 1; i >= 0; i--)
{
if (num[i] % 2 == 0)
{
if (!a)
num[i] = num[i] / 2;
else
num[i] = num[i] / 2 + 5;
a = false;
}
else
{
if (!a)
num[i] = num[i] / 2;
else
num[i] = num[i] / 2 + 5;
a = true;
}
}
}
bool odd()
{
if (num[0] % 2 == 1)
return true;
return false;
}

};

string s;
BNum inp;

void solve()
{
cin >> s;
inp = BNum(s);
if (inp.odd())
{
inp.m1();
inp.div2();
inp.clear0();
inp.output();
return;
}
inp.div2();
inp.m1();
if (inp.odd())
{
inp.clear0();
inp.output();
return;
}
inp.m1();
inp.clear0();
inp.output();
}

int main()
{
solve();
return 0;
}