結果

問題 No.1161 Many Powers
ユーザー 夜
提出日時 2020-08-20 03:28:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 830 ms
コンパイル使用メモリ 91,868 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 18:44:13
合計ジャッジ時間 2,315 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 5 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 32 ms
5,376 KB
testcase_09 AC 36 ms
5,376 KB
testcase_10 AC 14 ms
5,376 KB
testcase_11 AC 25 ms
5,376 KB
testcase_12 AC 13 ms
5,376 KB
testcase_13 AC 41 ms
5,376 KB
testcase_14 AC 62 ms
5,376 KB
testcase_15 AC 53 ms
5,376 KB
testcase_16 AC 70 ms
5,376 KB
testcase_17 AC 46 ms
5,376 KB
testcase_18 AC 33 ms
5,376 KB
testcase_19 AC 20 ms
5,376 KB
testcase_20 AC 73 ms
5,376 KB
testcase_21 AC 19 ms
5,376 KB
testcase_22 AC 75 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	long long ans = 0;
	for (long long i = 1; i < c; i++) {
		long long x = i;
		long long y = b;
		long long z = 1;
		while (y > 0) {
			if ((y & 1) == 1) {
				z = z * x % c;
			}
			x = x * x % c;
			y >>= 1;
		}
		ans += (a + (c - i)) / c * z;
		ans %= c;
	}
	cout << ans << endl;
}
0