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

Jamshid Sattarov (TUIT Urgench) Wrong test #6 help me friends please !!! [1] // Problem 1493. One Step from Happiness 14 Oct 2014 12:43
this is my solution
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
   long long a,b,s=0,d=0,k=0,jama,kk=0,ss=0,dd=0;
   cin>>b;
   a=b;
   b=b-1;
   while(b-1>0)
   { jama=b%10;
       k++;
       if(k<=3)
       {
           s+=jama;
       }
       else{
        d+=jama;
       }
       b/=10;

   }

   int i=0;
   if(s-d==0 )
   {
      i++;

   }

   a=a+1;
   int joma;
    while(a>0)
   { joma=a%10;
       kk++;
       if(kk<=3)
       {
           ss+=joma;
       }
       else{
        dd+=joma;
       }
       a/=10;

   }
   if(ss-dd==0 )
   {
      i++;

   }
   if(i>0)
   {
       cout<< "Yes";

   }
   else
    cout<< "No";
    return 0;
}
[delete]

Edited by author 02.11.2015 00:38

Edited by author 02.11.2015 00:38