結果
問題 | No.16 累乗の加算 |
ユーザー |
![]() |
提出日時 | 2016-11-02 11:38:26 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 676 bytes |
コンパイル時間 | 433 ms |
コンパイル使用メモリ | 21,248 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 05:17:41 |
合計ジャッジ時間 | 807 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:10:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%lld%lld", &x, &n); | ^~~~~~~~~~~~~~~~~~~~~~~~~ main.c:12:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%lld", &a[i]); | ^~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(void) { long long int x, n; long long int a[101]; long long int i, j; long long int total = 0; long long int subtotal, an; scanf("%lld%lld", &x, &n); for(i = 1;i <= n;i++){ scanf("%lld", &a[i]); } for(i = 1;i <= n;i++){ subtotal= 1; an = x; while(a[i] != 0){ //printf("a[%lld] = %lld %lld\n", i, a[i], an); if(a[i] % 2 == 1){ subtotal = (subtotal * an) % 1000003; } //for(j = 0;j < a[i];j++){ an = (an * an) % 1000003; a[i] /= 2; } //printf("subtotal = %lld\n", subtotal); total = (total + subtotal) % 1000003; } //printf("total = %lld\n", total % 1000003); printf("%lld\n", total); return 0; }