hdu 5373 The shortest problem
#include<bits/stdc++.h>
using namespace std;
int s[100],k;
int fnc(int x)
{
int ret=0;
while(x>0)
{
s[k++]=x%10;
ret+=x%10;
x/=10;
}
return ret;
}
int main()
{
int _=0,n,m,tp,f,ans;
while(~scanf("%d%d",&n,&m))
{
if(n==-1&&m==-1) break;
ans=k=0;
f=1;
n=fnc(n);
while(k--)
if(f)
ans+=s[k],f=0;
else
ans-=s[k],f=1;
while(m--)
{
k=0;
//printf("%d\n",n);
n+=fnc(n);
while(k--)
if(f)
ans+=s[k],f=0;
else
ans-=s[k],f=1;
}
printf("Case #%d: ",++_);
if(ans<0) ans=-ans;
if(ans%11==0) printf("Yes\n");
else printf("No\n");
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/