2 solutions
-
0
蒙对
#include <bits/stdc++.h> using namespace std; unsigned long long check(unsigned long long a,unsigned long long b,unsigned long long c){//龟速乘 (a * b) % c unsigned long long ret = 0; while(b > 0){ if(b & 1){ ret = (ret % c + a % c) % c; } a = (a % c + a % c) % c; b = b >> 1; } return ret; } int main(){ std::ios::sync_with_stdio(false); unsigned long long a,b,c,sum = 1; while(cin>>a>>b>>c){ sum = 1; while(b > 0){ if(b & 1){ sum = check(sum % c,a % c,c); } a = check(a % c,a % c,c); b = b >> 1; } cout<<sum<<endl; } return 0; }
Information
- ID
- 1551
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 8
- Tags
- # Submissions
- 156
- Accepted
- 21
- Uploaded By