模拟题
其实我没有找到写这份题解的意义何在,大概是为了提醒自己亦或是为了纪念什么。
有时候会特别模糊思维,看道这题的时候,感觉懂又感觉不懂,最后还是搜了题解,看了半天,然后才明白。
这大抵是我正式写的第一个模拟题,也许我真的比较笨,所以有些时候有些浅显的东西,反而要比复杂的东西用更多时间去明白。
所以,大概是想以后看看的,所以还是写了这个。
//#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#define LL __int64
#define ls v<<1
#define rs v<<1|1
//#define LOCAL
using namespace std;
const int INF=0x3ffffff;
const int MAXN=1000;
int digit[MAXN];
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
ios::sync_with_stdio(false);
int t,n,k,tail,point;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&k);
if(n>k)//因为一个自然数和另一个自然数的最小乘积是它本身,即另一个数为1的情况下
{
cout<<0<<endl;
continue;
}
point=tail=0;
digit[point]=k;
while(1)
{
int tmp=digit[point]*n+tail;
digit[++point]=tmp%10;
tail=tmp/10;
if(digit[point]==k && !tail)
break;
}
for(int i=point-1;i>=0;i--)
cout<<digit[i];
cout<<endl;
}
return 0;
}