結果

問題 No.16 累乗の加算
ユーザー kkslucy1kkslucy1
提出日時 2018-03-10 17:51:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 461 bytes
コンパイル時間 1,936 ms
コンパイル使用メモリ 146,132 KB
実行使用メモリ 10,868 KB
最終ジャッジ日時 2023-09-08 12:12:56
合計ジャッジ時間 2,227 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
10,868 KB
testcase_01 AC 10 ms
10,800 KB
testcase_02 AC 10 ms
10,812 KB
testcase_03 AC 10 ms
10,796 KB
testcase_04 AC 10 ms
10,796 KB
testcase_05 AC 10 ms
10,696 KB
testcase_06 AC 11 ms
10,780 KB
testcase_07 AC 10 ms
10,748 KB
testcase_08 AC 10 ms
10,728 KB
testcase_09 AC 10 ms
10,680 KB
testcase_10 AC 10 ms
10,696 KB
testcase_11 AC 10 ms
10,712 KB
testcase_12 AC 10 ms
10,800 KB
testcase_13 AC 10 ms
10,808 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:6: warning: ‘da’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  int da;
      ^~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define M 1000003
int main() {
	long long x;
	int n;
	cin >> x >> n;
	vector<long long> a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}

	vector<long long> nx(M+1);
	nx[0] = 1;
	int da;
	for (int i = 1;i <= M;i++) {
		nx[i] = (nx[i - 1] * x) % M;
		if (nx[i] == 1) {
			da = i;
		}
	}

	long long sum = 0;
	for (int i = 0;i < n;i++) {
		sum += nx[a[i] % da];
		sum %= M;
	}
	cout << sum << endl;


	return 0;
}
0