結果
| 問題 | 
                            No.129 お年玉(2)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             unko
                         | 
                    
| 提出日時 | 2015-01-16 23:58:27 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 538 bytes | 
| コンパイル時間 | 875 ms | 
| コンパイル使用メモリ | 71,384 KB | 
| 実行使用メモリ | 292,768 KB | 
| 最終ジャッジ日時 | 2024-06-22 13:01:24 | 
| 合計ジャッジ時間 | 9,312 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 2 TLE * 1 -- * 43 | 
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
const int mod = 1000000000;
map<pair<ll,ll>, ll> mm;
ll cmb(ll n, ll k) {
    if (k == 0 || n == k) return 1LL;
    pair<ll, ll> key = make_pair(n, k);
    if (mm.count(key)) return mm[key];
    return mm[key] = (cmb(n-1, k-1) + cmb(n-1, k)) % mod;
}
int main() {
    ll N, M;
    cin >> N >> M;
    ll t = (N - ((N / 1000) / M * 1000) * M) / 1000;
    cout << cmb(M, max(0LL, min(M, t))) % mod << endl;
    return 0;
}
            
            
            
        
            
unko