mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
27767e72ab
2800-2899
33 lines
449 B
C++
33 lines
449 B
C++
#include <stdio.h>
|
|
int main ()
|
|
{
|
|
int n,a,b,i,j,k,t=1;
|
|
int c[100];
|
|
while (scanf("%d %d %d",&n,&a,&b)!=EOF)
|
|
{
|
|
printf ("Case %d:",t++);
|
|
i=0;
|
|
while (n)
|
|
{
|
|
c[i]=n%b;
|
|
n/=b;
|
|
i++;
|
|
}
|
|
c[i]=0;
|
|
for (k=0;k<i-1;k++)
|
|
{
|
|
while (c[k]<a)
|
|
{
|
|
c[k]+=b;
|
|
c[k+1]--;
|
|
}
|
|
}
|
|
while (c[k]==0 && k)
|
|
k--;
|
|
while (k)
|
|
printf (" %d",c[k--]);
|
|
printf (" %d\n",c[0]);
|
|
}
|
|
return 0;
|
|
}
|