#include <stdio.h>
class CA
{
public:
void run();
int n,num;
};
void CA::run()
{
scanf("%d",&n);
int r,x,y,m;
num=0;
r=1;x=n;
while(x>0)
{
m=x%10;
y=n%r;
x=x/10;
if(m>1)
{
num+=(x+1)*r;
}
else if(m==1)
{
num+=x*r+y+1;
}
else if(m<1)
{
num+=x*r;
}
r*=10;
}
printf("%d\n",num);
}
int main()
{
// freopen("test.in","r",stdin);
CA *a=new CA;
a->run();
return 0;
}
1049. Counting Ones (30)
最新推荐文章于 2018-03-08 17:20:05 发布