結果
問題 | No.16 累乗の加算 |
ユーザー |
![]() |
提出日時 | 2018-10-09 20:01:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 479 bytes |
コンパイル時間 | 1,648 ms |
コンパイル使用メモリ | 165,740 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 16:39:32 |
合計ジャッジ時間 | 2,268 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;const int mod = 1e6+3;ll rui(ll x,ll a){ll res = 1;while(a > 0){if(a & 1) res = res * x % mod;x = x * x % mod;a >>= 1;}return res;}int main(){int x,n,a,ans = 0;cin >> x >> n;for(int i = 0; i < n; i++){cin >> a;ans += rui(x,a);ans %= mod;}cout << ans << endl;return 0;}