結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
C_kumo
|
| 提出日時 | 2019-01-22 23:51:39 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 546 bytes |
| コンパイル時間 | 656 ms |
| コンパイル使用メモリ | 30,208 KB |
| 実行使用メモリ | 7,168 KB |
| 最終ジャッジ日時 | 2024-09-16 04:20:07 |
| 合計ジャッジ時間 | 6,533 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 TLE * 1 -- * 11 |
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ANS (1000000+3)
#define DEV 3
#define DEBUG 0
int main(void)
{
char x,n,i;
long a,g,h,j,tmp,ans=0;
scanf("%hhd %hhd",&x,&n);
for (i=0;i<n;i++) {
scanf("%ld",&a);
g = a / DEV;
h = a % DEV;
tmp = 1;
if (DEBUG) printf("g=%ld\n",g);
for (j=0;j<g;j++) {
tmp *= pow(x,DEV);
tmp = tmp % ANS;
}
tmp *= pow(x,h);
tmp = tmp % ANS;
if (DEBUG) printf("%hhd ^ %ld = %ld\n",x,a,tmp);
ans += tmp;
ans = ans % ANS;
}
printf("%ld\n",ans);
return 0;
}
C_kumo