結果

問題 No.129 お年玉(2)
ユーザー tubo28tubo28
提出日時 2015-01-16 23:38:23
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 542 ms / 5,000 ms
コード長 1,490 bytes
コンパイル時間 1,013 ms
実行使用メモリ 3,724 KB
最終ジャッジ日時 2023-01-04 19:12:29
合計ジャッジ時間 14,103 ms
ジャッジサーバーID
(参考情報)
judge16 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
3,616 KB
testcase_01 AC 542 ms
3,668 KB
testcase_02 AC 2 ms
3,372 KB
testcase_03 AC 2 ms
3,480 KB
testcase_04 AC 1 ms
3,516 KB
testcase_05 AC 220 ms
3,672 KB
testcase_06 AC 347 ms
3,568 KB
testcase_07 AC 428 ms
3,636 KB
testcase_08 AC 289 ms
3,680 KB
testcase_09 AC 392 ms
3,572 KB
testcase_10 AC 444 ms
3,576 KB
testcase_11 AC 277 ms
3,644 KB
testcase_12 AC 362 ms
3,636 KB
testcase_13 AC 381 ms
3,572 KB
testcase_14 AC 367 ms
3,628 KB
testcase_15 AC 302 ms
3,668 KB
testcase_16 AC 343 ms
3,724 KB
testcase_17 AC 419 ms
3,568 KB
testcase_18 AC 393 ms
3,672 KB
testcase_19 AC 421 ms
3,572 KB
testcase_20 AC 419 ms
3,720 KB
testcase_21 AC 530 ms
3,568 KB
testcase_22 AC 292 ms
3,692 KB
testcase_23 AC 458 ms
3,672 KB
testcase_24 AC 439 ms
3,568 KB
testcase_25 AC 278 ms
3,636 KB
testcase_26 AC 285 ms
3,568 KB
testcase_27 AC 277 ms
3,576 KB
testcase_28 AC 535 ms
3,644 KB
testcase_29 AC 1 ms
3,440 KB
testcase_30 AC 2 ms
3,524 KB
testcase_31 AC 1 ms
3,528 KB
testcase_32 AC 2 ms
3,456 KB
testcase_33 AC 4 ms
3,460 KB
testcase_34 AC 3 ms
3,524 KB
testcase_35 AC 4 ms
3,452 KB
testcase_36 AC 5 ms
3,584 KB
testcase_37 AC 6 ms
3,464 KB
testcase_38 AC 58 ms
3,588 KB
testcase_39 AC 90 ms
3,528 KB
testcase_40 AC 258 ms
3,720 KB
testcase_41 AC 156 ms
3,640 KB
testcase_42 AC 66 ms
3,524 KB
testcase_43 AC 65 ms
3,588 KB
testcase_44 AC 538 ms
3,692 KB
testcase_45 AC 37 ms
3,568 KB
testcase_46 AC 101 ms
3,536 KB
testcase_47 AC 518 ms
3,624 KB
testcase_48 AC 306 ms
3,712 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