結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
Ysmr_Ry
|
| 提出日時 | 2014-11-11 00:08:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 483 bytes |
| コンパイル時間 | 125 ms |
| コンパイル使用メモリ | 23,424 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 04:46:47 |
| 合計ジャッジ時間 | 769 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | scanf( "%lld%d", &x, &N );
| ~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp:34:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
34 | scanf( "%lld", &a );
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include<cstdio>
#define rep(i,a) for(int i=0;i<(a);++i)
typedef long long ll;
const int mod = 1000003;
ll powMod( ll x, ll n )
{
ll ret = 1;
while( n )
{
if( n&1 )
ret = (ret*x)%mod;
x = (x*x)%mod;
n >>= 1;
}
return ret;
}
int main()
{
ll x;
int N;
scanf( "%lld%d", &x, &N );
ll ans = 0;
rep( i, N )
{
ll a;
scanf( "%lld", &a );
ans = (ans + powMod( x, a )) % mod;
}
printf( "%lld\n", ans );
return 0;
}
Ysmr_Ry