結果
問題 |
No.129 お年玉(2)
|
ユーザー |
![]() |
提出日時 | 2019-08-16 06:28:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 482 ms / 5,000 ms |
コード長 | 746 bytes |
コンパイル時間 | 787 ms |
コンパイル使用メモリ | 91,784 KB |
実行使用メモリ | 104,704 KB |
最終ジャッジ日時 | 2024-09-21 14:57:37 |
合計ジャッジ時間 | 10,013 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <cstring> #include <math.h> #include <cmath> #include <limits.h> #include <map> #include <unordered_map> #include <set> #include <queue> #include <algorithm> #include <functional> #include <stdio.h> using namespace std; long long MOD = 1000000007; int C[10001][10001]; long long func( int n, int r ) { if ( n/2 < r ) { r = n-r; } if ( r == 0 ) { return 1; } if ( C[n][r] > 0 ) { return C[n][r]; } C[n][r] = ( func( n-1, r ) + func( n-1, r-1 ) ) % ( (long long)1e9 ); return C[n][r]; } int main() { long long N,M; cin >> N >> M; int a = (N/1000)%M; long long ans = func( M, a ); cout << ans << endl; return 0; }