結果
| 問題 | 
                            No.16 累乗の加算
                             | 
                    
| コンテスト | |
| ユーザー | 
                             goodbaton
                         | 
                    
| 提出日時 | 2015-07-22 21:31:08 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 921 bytes | 
| コンパイル時間 | 494 ms | 
| コンパイル使用メモリ | 72,328 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-07-08 11:54:28 | 
| 合計ジャッジ時間 | 1,042 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 5 WA * 9 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |     scanf("%d%d",&x,&N);
      |     ~~~~~^~~~~~~~~~~~~~
main.cpp:32:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
            
            ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>
typedef long long ll;
using namespace std;
#define mod 1000003
#define INF 1000000000
#define LLINF 2000000000000000000LL
#define LOG2 26
#define SIZE 100
int main(){
    int x,N;
    ll N_2[LOG2],ans=0;
    int a[SIZE];
    
    scanf("%d%d",&x,&N);
    
    for(int i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    
    N_2[0]=(ll)x;
    
    for(int i=0;i<LOG2-1;i++){
        N_2[i+1]=(N_2[i]*N_2[i])%mod;
    }
    
    for(int i=0;i<N;i++){
        int b = 1;
        
        for(int j=0;a[i]>0;j++){
            if(a[i]%2){
                b=(b*N_2[j])%mod;
            }
            a[i]/=2;
        }
        
        ans=(ans+b)%mod;
    }
    
    printf("%d\n",(int)ans);
    return 0;
}
            
            
            
        
            
goodbaton