結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
rodea
|
| 提出日時 | 2017-12-24 13:23:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 429 bytes |
| コンパイル時間 | 713 ms |
| コンパイル使用メモリ | 65,180 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-17 18:32:55 |
| 合計ジャッジ時間 | 1,289 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 10 |
ソースコード
#include<iostream>
using namespace std;
typedef unsigned long long ull;
ull M = 1000003;
ull power(ull x, ull n)
{
ull tmp = 1;
if (n > 0)
{
if (n % 2 == 0) tmp = power((x*x) % M, n / 2) % M;
else tmp = (power((x*x) % M, n / 2) * x) % M;
}
return tmp;
}
int main()
{
int x, n, i;
ull a[101], sum = 0;
cin >> x >> n;
for (i = 1; i <= n; i++)
{
cin >> a[i];
sum += power(x, a[i]);
}
cout << sum << endl;
}
rodea