結果
| 問題 | 
                            No.16 累乗の加算
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tetsuzuki1115
                         | 
                    
| 提出日時 | 2018-01-05 17:03:25 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                MLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 691 bytes | 
| コンパイル時間 | 872 ms | 
| コンパイル使用メモリ | 77,860 KB | 
| 実行使用メモリ | 784,756 KB | 
| 最終ジャッジ日時 | 2024-12-23 06:08:25 | 
| 合計ジャッジ時間 | 27,607 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | MLE * 14 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:14: warning: iteration 99999999 invokes undefined behavior [-Waggressive-loop-optimizations]
   32 |         M[i] = a;
      |         ~~~~~^~~
main.cpp:29:24: note: within this loop
   29 |     for ( int i = 1; i <= 100000000; i++ ) {
      |                      ~~^~~~~~~~~~~~
            
            ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;
long long MOD = 1000003;
long long M[100000000];
int main() {
    
    int x,N;
    cin >> x >> N;
    
    
    M[0] = 1;
    long long a = 1;
    for ( int i = 1; i <= 100000000; i++ ) {
        a *= x;
        a %= MOD;
        M[i] = a;
    }
    
    long long ans =  0;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        ans += M[a];
        ans %= MOD;
    }
    
    cout << ans << endl;
    
    return 0;
}
            
            
            
        
            
tetsuzuki1115