|
|
back to boardAC in c++ Posted by Yucheng 15 Feb 2019 12:48 #include<iostream> using namespace std; int sum(int temp); int main(){ int a[6]; scanf("%1d%1d%1d%1d%1d%1d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]); int first=a[0]*100+a[1]*10+a[2]; int second=a[3]*100+a[4]*10+a[5]; if(a[3]==9&&a[4]==9&&a[5]==9){ cout<<"No"; return 0; } int pre=second-1; int next=second+1; if((sum(pre)==(a[0]+a[1]+a[2]))||(sum(next)==(a[0]+a[1]+a[2]))){ cout<<"Yes"; }else{ cout<<"No"; }
return 0; } int sum(int temp){ int count=0; do{ count+=(temp%10); temp/=10; }while(temp/10!=0); count+=temp; return count; } |
|
|