//poj 2897 //sep9 #include<iostream> using namespace std; int ans[128],ansp; int main() { int cases,n,k; scanf("%d",&cases); while(cases--){ memset(ans,0,sizeof(ans)); ansp=0; scanf("%d%d",&n,&k); int flag=1,c=0,times=0; ans[ansp++]=k; while(1){ int p=(n*k+c)%10; if(p==ans[0]&&(n*k+c)/10==0) break; ans[ansp++]=p; c=(n*k+c)/10; k=p; ++times; } if(ans[ansp-1]==0) puts("0"); else{ for(int i=ansp-1;i>=0;--i) printf("%d",ans[i]); printf("\n"); } } return 0; }
时间: 2024-10-12 15:27:17