如题,这是一道简单数学题。
首先推式子:
所以需要算出来 ,快速幂即可。
c++ 代码:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m;
long long quick_pow(ll x,ll y,ll p)//快速幂
{
if(y==0) return 1;
ll res=quick_pow(x,y>>1,p)%p;
if(y&1) return res*res%p*x%p;
else return res*res%p;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
cout<<quick_pow(10,n,m*m)/m;
return 0;
}Python 代码,自带 pow 函数,可实现取余:
n, m = map(int, input().split())
print(pow(10, n, m * m) // m)