|
本帖最后由 Settwarl 于 2014-10-28 17:51 编辑
- #include<iostream>
- using namespace std;
- int n,m,k,x;
- int f(int k)
- {
- int base=10%n;
- int ans=1;
- while(k>0)
- {
- if(k%2==1)
- ans=(ans*base)%n;
- base=(base*base)%n;
- k=k/2;
- }
- return (m%n*ans%n)%n;
- }
- int main()
- {
- cin>>n>>m>>k>>x;
- cout<<(x+f(k))%n<<endl;
- return 0;
- }
复制代码 |
|