結果
問題 |
No.1161 Many Powers
|
ユーザー |
![]() |
提出日時 | 2020-08-13 16:48:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 75 ms / 2,000 ms |
コード長 | 1,015 bytes |
コンパイル時間 | 815 ms |
コンパイル使用メモリ | 93,468 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-09 19:19:00 |
合計ジャッジ時間 | 2,265 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 |
ソースコード
/* -*- coding: utf-8 -*- * * 1161.cc: No.1161 Many Powers - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ const int MAX_C = 100000; /* typedef */ typedef long long ll; /* global variables */ int cbss[MAX_C + 1]; /* subroutines */ int powmod(int a, ll n, int mod) { // a^n % mod int pm = 1; while (n > 0) { if (n & 1) pm = (ll)pm * a % mod; a = (ll)a * a % mod; n >>= 1; } return pm; } /* main */ int main() { ll a, b; int c; scanf("%lld%lld%d", &a, &b, &c); cbss[0] = 0; for (int i = 0; i < c; i++) cbss[i + 1] = (cbss[i] + powmod(i, b, c)) % c; int sum = ((ll)cbss[c] * (a / c % c) % c + cbss[a % c + 1]) % c; printf("%d\n", sum); return 0; }