結果
問題 |
No.8046 yukicoderの過去問
|
ユーザー |
|
提出日時 | 2019-04-01 21:50:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 997 bytes |
コンパイル時間 | 1,653 ms |
コンパイル使用メモリ | 194,760 KB |
最終ジャッジ日時 | 2025-01-07 01:00:15 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 TLE * 3 |
コンパイルメッセージ
main.cpp: In function ‘void solve()’: main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | scanf("%d%d", &K, &N); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:24:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 24 | scanf("%d", &X[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include "bits/stdc++.h" using namespace std; #define mod 1000000007 #define dom 998244353 #define all(c) begin(c),end(c) #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) //template <typename T> bool &chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } //template <typename T> bool &chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } #define long long long #define List vector #define var auto #define Count size() #define Length size() int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑ void solve() { int K, N; scanf("%d%d", &K, &N); vector<int> X(N); for (int i = 0; i < N; ++i) { scanf("%d", &X[i]); } vector<int> dp(K + 1); dp[0] = 1; for (int i = 1; i <= K; ++i) { for (int j = 0; j < N && X[j] <= i; j++) { dp[i] += dp[i - X[j]]; if (dp[i] > mod)dp[i] -= mod; } } printf("%d\n", dp[K]); } int main() { //cin.tie(0); //ios::sync_with_stdio(false); solve(); return 0; }