結果
問題 | No.16 累乗の加算 |
ユーザー |
![]() |
提出日時 | 2020-04-30 17:09:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 691 bytes |
コンパイル時間 | 673 ms |
コンパイル使用メモリ | 72,332 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-16 04:13:34 |
合計ジャッジ時間 | 1,276 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 14 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/iostream:39, from main.cpp:1: In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]', inlined from 'int main()' at main.cpp:41:10: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:202:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized] 202 | { return _M_insert(__n); } | ~~~~~~~~~^~~~~ main.cpp: In function 'int main()': main.cpp:34:15: note: 'ans' was declared here 34 | ll a, ans; | ^~~
ソースコード
#include <iostream>#include <vector>#include <string>#include <list>#include <queue>#include <algorithm>#define rep(i, n) for(i = 0; i < (n); i++)#define chmax(x, y) x = max(x, y)#define chmin(x, y) x = min(x, y)#define MOD 1000003#define PI 3.14159265358979323846#define INF 1 << 30using namespace std;typedef long long ll;typedef pair<int, int> pp;ll Pow(ll n, ll k) {ll ans = 1, a = n % MOD;while (k > 0) {if (k & 1) {ans *= a;ans %= MOD;}a *= a;a %= MOD;k >>= 1;}return ans;}int main(void) {int num, i, k;ll a, ans;cin >> a >> num;rep(i, num) {cin >> k;ans += Pow(a, k);ans %= MOD;}cout << ans << "\n";return 0;}