https://ac.nowcoder.com/acm/contest/548/B
题解:可以自己手动模拟一下,然后你会发现,一个数除的最后一位只与上一位的余有关。所以,不断 *10 然后 %b 就好。但是太慢。。加个快速幂。a*(10,n-1) %b 然后 剩下的 *10再/b 就好
#include<bits/stdc++.h>
#define MID (l+r)>>1
#define lson step<<1
#define rson step<<1|1
#define LL long long
using namespace std;
const int maxn=1005;
LL m,n,k1,k2;
LL qpow(LL c,LL d)
{
LL res=1;
while(d)
{
if(d&1)
res*=c,res%=n;
c*=c;
c%=n;
d>>=1;
}
return res%n;
}
int main()
{
ios::sync_with_stdio(false);
int t;
cin>>t;
while(t--)
{
cin>>m>>n>>k1>>k2;
for(int i=k1;i<=k2;i++)
{
LL z=(m%n*qpow(10,i-1))%n;
cout << z*10/n;
}
cout << endl;
}
return 0;
}