Description
保证a,b均不超过6位(良心数据,良心出题人)
直接复制格式会爆炸,凑合着看吧
Analysis
直接模拟。
想怎么玩就怎么玩。
0下移其实就是让那个数*10,其他就没什么了。
Code
#include<cstdio>
#include<cmath>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;
ll x,y,z;
int f(ll x)
{
return log10(x)+1;
}
int main()
{
int lyd=0;
for(scanf("%lld %lld",&x,&y);x || y;scanf("%lld %lld",&x,&y))
{
printf("Problem %d\n",++lyd);
z=x*y;
int ws=f(z);
fo(i,1,ws-f(x)) printf(" ");
printf("%lld\n",x);
fo(i,1,ws-f(y)) printf(" ");
printf("%lld\n",y);
fo(i,1,ws) printf("-");printf("\n");
ll t=0,k=0,c=0,s=1,pos=0;
int tot=0;
for(;y;y/=10)
{
k++;
if(y%10==0) {s=s*10;continue;}
else t=s*(y%10),s=1;
c=t*x;
fo(i,1,ws-f(c)-pos) printf(" ");
printf("%lld\n",c);
pos=k,tot++;
}
if(tot==1) continue;
fo(i,1,ws) printf("-");printf("\n");
printf("%lld\n",z);
}
return 0;
}