結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2016-05-11 22:47:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 36 ms / 5,000 ms |
コード長 | 448 bytes |
コンパイル時間 | 511 ms |
コンパイル使用メモリ | 55,308 KB |
実行使用メモリ | 11,876 KB |
最終ジャッジ日時 | 2024-07-16 01:54:39 |
合計ジャッジ時間 | 1,402 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <iostream> using namespace std; int memo[101][20001]; int mod=1000000007; int rec(int N, int S){ if( S<0 ) return 0; if( N==1 ) return memo[N][S]=1; if( memo[N][S]!=-1) return memo[N][S]; memo[N][S]=0; return memo[N][S]=(rec(N,S-N)+rec(N-1,S))%mod; } int main(){ int N,S,K; for( int i = 0 ; i <101; i++ ) for( int j = 0 ; j < 20001; j++) memo[i][j]=-1; cin >> N >> S >> K; S-=K*N*(N-1)/2; cout << rec(N,S); }