ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1493. One Step from Happiness

The solution is correct but test1 says it's wrong :/
Posted by Arusyak 16 Mar 2016 20:19
//Timus1493

#include <iostream>
using namespace std;

//Creates a copy and does not change the argument
int sum_of_3(int num)
{
    int result = 0;

    for (int i = 1; i <= 3; i++)
    {
        result += num % 10;
        num /= 10;
    }
    return result;
}

int main ()
{
    int num;
    cin >> num;

    int digit = num % 10, right = sum_of_3(num), left = sum_of_3(num / 1000);



    if ((left > right  && digit == 9) || (left < right  && digit == 0))
        cout << "No \n";
    else
        cout << "Yes \n";

    cout << num;

    return 0;


}
Re: The solution is correct but test1 says it's wrong :/
Posted by ToadMonster 16 Mar 2016 20:31
Fix output as task required - remove spaces after Yes and No, remove "cout << num;".