結果

問題 No.129 お年玉(2)
ユーザー tubo28tubo28
提出日時 2015-01-16 23:38:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 508 ms / 5,000 ms
コード長 1,490 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 68,940 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 16:26:05
合計ジャッジ時間 12,936 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
4,380 KB
testcase_01 AC 507 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 201 ms
4,376 KB
testcase_06 AC 326 ms
4,376 KB
testcase_07 AC 390 ms
4,376 KB
testcase_08 AC 272 ms
4,376 KB
testcase_09 AC 370 ms
4,380 KB
testcase_10 AC 426 ms
4,380 KB
testcase_11 AC 259 ms
4,380 KB
testcase_12 AC 335 ms
4,380 KB
testcase_13 AC 348 ms
4,376 KB
testcase_14 AC 335 ms
4,376 KB
testcase_15 AC 280 ms
4,380 KB
testcase_16 AC 321 ms
4,376 KB
testcase_17 AC 389 ms
4,376 KB
testcase_18 AC 361 ms
4,376 KB
testcase_19 AC 395 ms
4,376 KB
testcase_20 AC 380 ms
4,380 KB
testcase_21 AC 490 ms
4,380 KB
testcase_22 AC 263 ms
4,376 KB
testcase_23 AC 419 ms
4,376 KB
testcase_24 AC 402 ms
4,380 KB
testcase_25 AC 259 ms
4,380 KB
testcase_26 AC 259 ms
4,376 KB
testcase_27 AC 255 ms
4,376 KB
testcase_28 AC 494 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 4 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 5 ms
4,376 KB
testcase_36 AC 5 ms
4,380 KB
testcase_37 AC 5 ms
4,380 KB
testcase_38 AC 54 ms
4,380 KB
testcase_39 AC 83 ms
4,376 KB
testcase_40 AC 244 ms
4,376 KB
testcase_41 AC 148 ms
4,380 KB
testcase_42 AC 61 ms
4,380 KB
testcase_43 AC 60 ms
4,376 KB
testcase_44 AC 508 ms
4,380 KB
testcase_45 AC 34 ms
4,376 KB
testcase_46 AC 94 ms
4,376 KB
testcase_47 AC 473 ms
4,376 KB
testcase_48 AC 280 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

ll mod = 1000000000;

ll N,M;
int main(){

    while(cin>>N>>M){
        N/=1000;
        ll rem = N - N/M * M;

        vi x = {1,1};
        rep(i,M-1){
            vi y(x.size()+1);
            y[0] = 1;
            rep(i,x.size()-1){
                y[i+1] = (x[i+1]+x[i])%mod;
            }
            y.back() = y[0];
            dump(y);
            swap(x,y);
        }
        cout << x[rem] << endl;
        // cout << nCr(M,rem) << endl;
    }
}
0