結果
問題 | No.1035 Color Box |
ユーザー | ningenMe |
提出日時 | 2019-02-27 14:32:46 |
言語 | C++11 (gcc 11.4.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,747 bytes |
コンパイル時間 | 607 ms |
コンパイル使用メモリ | 84,060 KB |
実行使用メモリ | 69,760 KB |
最終ジャッジ日時 | 2024-06-23 05:09:27 |
合計ジャッジ時間 | 7,424 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | TLE | - |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 34 ms
34,944 KB |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | AC | 10 ms
7,808 KB |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | AC | 176 ms
17,664 KB |
testcase_12 | AC | 1,147 ms
35,328 KB |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 1 ms
6,940 KB |
testcase_18 | AC | 1 ms
6,940 KB |
testcase_19 | RE | - |
testcase_20 | AC | 1 ms
6,944 KB |
testcase_21 | AC | 1 ms
6,940 KB |
testcase_22 | AC | 1 ms
6,944 KB |
testcase_23 | AC | 1 ms
6,940 KB |
testcase_24 | AC | 1 ms
6,944 KB |
testcase_25 | AC | 1 ms
6,940 KB |
testcase_26 | AC | 1 ms
6,940 KB |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | AC | 1 ms
6,944 KB |
testcase_29 | AC | 1 ms
6,940 KB |
testcase_30 | AC | 2 ms
6,940 KB |
testcase_31 | AC | 2 ms
6,940 KB |
testcase_32 | AC | 2 ms
6,940 KB |
testcase_33 | AC | 2 ms
6,940 KB |
testcase_34 | AC | 2 ms
6,940 KB |
testcase_35 | AC | 2 ms
6,940 KB |
testcase_36 | AC | 1 ms
6,944 KB |
testcase_37 | AC | 2 ms
6,940 KB |
ソースコード
#include <iostream> #include <fstream> #include <cmath> #include <cstdlib> #include <ctime> #include <algorithm> #include <numeric> #include <functional> #include <string> #include <vector> #include <bitset> #include <map> #include <set> #include <stack> #include <queue> #include <deque> using namespace std; using ll = long long; #define REP(i,n) for(long long i = 0; i < (n); i++) #define FOR(i, m, n) for(long long i = (m);i < (n); ++i) #define ALL(obj) (obj).begin(),(obj).end() template<class T> using V = vector<T>; template<class T, class U> using P = pair<T, U>; const ll MOD = (ll)1e9 + 7; const ll MOD2 = 998244353; const ll LLINF = (ll)1e18; const ll INTINF = (ll)1e9; const long double PI = 3.1415926535897932384626433; template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } } template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; } template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; } template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; } template <template <class tmp> class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } void print(void) { cout << endl; } template <class Head> void print(Head&& head) { cout << head; print(); } template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); } template <class T> void chmax(T& a, const T b) { a = max<T>(a, b); } template <class T> void chmin(T& a, const T b) { a = min<T>(a, b); } void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; } void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; } void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; } ll dp[10005][10005]; ll rec(int n, int m) { if (n < 0 || m < 0) return 0; if (dp[n][m]) return dp[n][m]; if (n == 0) return dp[n][m] = 1; if (n > m) { dp[n][m] += (rec(n - 1, m) * m) % MOD; dp[n][m] %= MOD; } dp[n][m] += (rec(n - 1, m - 1) * m) % MOD; dp[n][m] %= MOD; return dp[n][m]; } int main() { int N, M; cin >> N >> M; cout << rec(N, M) << endl; return 0; }