結果
問題 |
No.129 お年玉(2)
|
ユーザー |
![]() |
提出日時 | 2015-05-30 15:43:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,694 bytes |
コンパイル時間 | 710 ms |
コンパイル使用メモリ | 88,480 KB |
実行使用メモリ | 394,448 KB |
最終ジャッジ日時 | 2024-07-06 12:45:45 |
合計ジャッジ時間 | 54,764 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 44 WA * 2 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <algorithm> // require sort next_permutation count __gcd reverse etc. #include <cstdlib> // require abs exit atof atoi #include <cstdio> // require scanf printf #include <functional> #include <numeric> // require accumulate #include <cmath> // require fabs #include <climits> #include <limits> #include <cfloat> #include <iomanip> // require setw #include <sstream> // require stringstream #include <cstring> // require memset #include <cctype> // require tolower, toupper #include <fstream> // require freopen #include <ctime> // require srand #define rep(i,n) for(int i=0;i<(n);i++) #define ALL(A) A.begin(), A.end() using namespace std; typedef long long ll; typedef pair<int, int> P; const int MOD = (int)1e9; const int MAX_N = (int)1e4 + 4; int c[MAX_N][MAX_N]; void calc_comb (void ){ memset (c, 0, sizeof (c ) ); c[0][0] = 1; for (int i = 1; i < MAX_N; i++ ){ rep (j, i+1 ){ c[i-j][j] = (c[i-j][j] + (j > 0 ? c[i-j][j-1] : 0 ) ) % MOD; c[i-j][j] = (c[i-j][j] + (i - j > 0 ? c[i-j-1][j] : 0 ) ) % MOD; } // end rep } // end for /* rep (i, MAX_N ) { rep (j, MAX_N ){ cerr << c[i][j] << (j != MAX_N - 1 ? ' ' : '\n' ); } // end rep } // end rep */ } int comb (int n, int m ){ if (n < m ) swap (n, m ); return c[n-m][m]; } int main() { calc_comb (); ios_base::sync_with_stdio(0); ll N, M; cin >> N >> M; N /= 1000LL; int res = 0; if (N == 0LL ){ res = 0; }else if (N % M == 0LL ){ res = 1; }else{ res = comb((int)M, (int)(N % M ) ); } // end if cout << res << endl; return 0; }