結果
問題 |
No.16 累乗の加算
|
ユーザー |
![]() |
提出日時 | 2015-05-18 18:09:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 562 bytes |
コンパイル時間 | 240 ms |
コンパイル使用メモリ | 22,784 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-06 05:28:17 |
合計ジャッジ時間 | 868 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 WA * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d%d", &x, &N); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:11:42: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | for (int i = 0; i < N; i++) scanf("%d", a + i); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <cstdio> using namespace std; #define MOD 1000003 #define N_MAX 100 int x, N; int a[N_MAX]; int main() { scanf("%d%d", &x, &N); for (int i = 0; i < N; i++) scanf("%d", a + i); long long res = 0; for (int i = 0; i < N; i++) { long long yy = 1; while (2 < a[i]) { long long y, z; y = a[i] ? x : 1; z = 1; while (z * 2 < a[i]) { y *= y; y %= MOD; z *= 2; } a[i] -= z; yy *= y; } while (a[i]) { yy *= x; yy %= MOD; a[i]--; } res += yy; res %= MOD; } printf("%lld\n", res); return 0; }