結果
問題 |
No.695 square1001 and Permutation 4
|
ユーザー |
![]() |
提出日時 | 2018-06-08 22:54:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 661 bytes |
コンパイル時間 | 2,014 ms |
コンパイル使用メモリ | 201,188 KB |
最終ジャッジ日時 | 2025-01-05 10:51:48 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 MLE * 5 |
ソースコード
#include <bits/stdc++.h> using namespace std; using int64 = long long; int N, M, X[5]; unordered_map< int, int64 > dp; const int64 mod = 100000000000000007; int main() { cin >> N >> M; for(int i = 0; i < M; i++) cin >> X[i]; dp[0] = 1; for(int k = 0; k < N; k++) { if(dp.count(k)) { for(int i = 0; i < M; i++) { if(k + X[i] < N) { dp[k + X[i]] += dp[k]; if(dp[k + X[i]] >= mod) dp[k + X[i]] -= mod; } } if(k == N - 1) { cout << dp[N - 1] << endl; return 0; } dp.erase(k); } if(k == N - 1) { cout << dp[N - 1] << endl; return 0; } } }