結果
問題 |
No.16 累乗の加算
|
ユーザー |
|
提出日時 | 2023-08-17 20:40:48 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 591 bytes |
コンパイル時間 | 226 ms |
コンパイル使用メモリ | 29,952 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-26 20:57:32 |
合計ジャッジ時間 | 807 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include<stdio.h> #include<stdlib.h> #define M 1000003 long long func(long long x,long long a){ if(a==0){ return 1; } if(a%2==0){ long long t=func(x,a/2)%M; return (t*t)%M; } else{ return x*func(x,a-1)%M; } } int main(){ long long x,n; long long a[102]; scanf("%lld%lld",&x,&n); for(int i=0;i<n;i++){ scanf("%lld",&a[i]); } long long ans=0; for(int i=0;i<n;i++){ // printf("%lld ",func(x,a[i])); ans=(ans+func(x,a[i]))%M; } printf("%lld",ans); return 0; }