Saratov State University :: Online Contester


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

::Poll
Are you registered on Codeforces?
Yes
No
What is it???

[results]

::webboard

To Administrator
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;
}


see sub-tree reply to that message


::Login
Forgot password?

::News
22.10.12 - The problems from the Southern Subregional Programming Contest 2012 added to the problemset archive (542 - 553).
22.10.12 - After the start of the contest the statements in PDF will be available by the link.
23.10.11 - The problems from the Southern Subregional Programming Contest 2011 added to the problemset archive (530 - 541).

::Counter

Server time: 2017-11-24 13:46:49Online Contester Team © 2002 - 2016. All rights reserved.