結果
| 問題 | No.1161 Many Powers |
| ユーザー |
chocorusk
|
| 提出日時 | 2020-08-12 00:35:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 133 ms / 2,000 ms |
| コード長 | 975 bytes |
| 記録 | |
| コンパイル時間 | 1,312 ms |
| コンパイル使用メモリ | 122,180 KB |
| 最終ジャッジ日時 | 2025-01-12 20:46:37 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 |
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll powmod(ll a, ll k, ll MOD){
ll ap=a, ans=1;
while(k){
if(k&1){
ans*=ap;
ans%=MOD;
}
ap=ap*ap;
ap%=MOD;
k>>=1;
}
return ans;
}
int main()
{
ll a, b, c;
cin>>a>>b>>c;
int r=a%c;
ll ans=0;
for(int i=1; i<=c-1; i++){
(ans+=powmod(i, b, c))%=c;
}
ans=ans*(a/c%c)%c;
for(int i=1; i<=r; i++) (ans+=powmod(i, b, c))%=c;
cout<<ans<<endl;
return 0;
}
chocorusk