結果

問題 No.695 square1001 and Permutation 4
ユーザー nikutto_nikutto_
提出日時 2018-06-09 19:47:15
言語 C++11
(gcc 13.3.0)
結果
MLE  
実行時間 -
コード長 543 bytes
コンパイル時間 1,593 ms
コンパイル使用メモリ 168,560 KB
実行使用メモリ 115,872 KB
最終ジャッジ日時 2024-07-22 19:31:46
合計ジャッジ時間 12,793 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 3 MLE * 1 -- * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

using ll=long long;
const ll MOD=100000000000000007;


int main(){
    int n,m;
    cin>>n>>m;
    vector<int> x(m);
    for(int i=0;i<m;i++) cin>>x[i];
    map<int,ll> dp;
    dp[0]=1;
    for(int i=0;i<n-1;i++){
        for(int j=0;j<m;j++){
            if(i+x[j]<n){
                dp[i+x[j]]+=dp[i];
                if(dp[i+x[j]]>=MOD){
                    dp[i+x[j]]-=MOD;
                }
            }
        }
        dp.erase(dp.find(i));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}
0