Tachibana Kanade Loves Probability 牛客练习赛43 快速幂+快速除
链接:https://ac.nowcoder.com/acm/contest/548/B
快速幂取模+快速除
#include<bits/stdc++.h>
using namespace std;
long long m,n,k1,k2;
long long powerMod(int a,long long b){
long long ans=m;
a=a%n;
while(b>0){
if(b&1) ans=(long long)ans*a%n;
a=(long long)a*a%n;
b/=2;
}
return ans;
}
int main(){
std::ios::sync_with_stdio(false);
int t;
cin>>t;
while(t--){
cin>>m>>n>>k1>>k2;
long long p,q;
p=powerMod(10,k1-1);
for(int i=k1;i<=k2;i++)
{
cout<<p*10/n;
p=p*10%n;
}
cout<<endl;
}
}