結果
問題 | No.16 累乗の加算 |
ユーザー |
|
提出日時 | 2020-04-04 11:50:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 531 bytes |
コンパイル時間 | 1,874 ms |
コンパイル使用メモリ | 167,536 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 07:08:59 |
合計ジャッジ時間 | 2,604 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i, n) for (int i = 0; i < (int)(n); i++)#define llong long longconst int DIVISOR = 1000003;long multi(long base, int exp) {if(exp == 0) return 1;if(exp == 1) return base;return (multi(base, exp/2) * multi(base, exp/2) * multi(base, exp%2)) % DIVISOR;}int main() {int x, n;cin >> x >> n;llong result = 0;rep(i, n) {int a;cin >> a;result += multi((long)x, a);}cout << result % DIVISOR << endl;}