結果

問題 No.129 お年玉(2)
ユーザー IL_mstaIL_msta
提出日時 2015-07-03 06:36:36
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,144 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 85,024 KB
実行使用メモリ 394,048 KB
最終ジャッジ日時 2023-09-22 05:58:17
合計ジャッジ時間 87,372 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:64:31: warning: iteration 5000 invokes undefined behavior [-Waggressive-loop-optimizations]
  rep(i,maxC)rep(j,maxC)c[i][j]=-1;
                        ~~~~~~~^~~
main.cpp:17:39: note: within this loop
 #define REP(i, x, n) for(int i = x; i < n; i++)
                                       ^
main.cpp:18:18: note: in expansion of macro ‘REP’
 #define rep(i,n) REP(i,0,n)
                  ^~~
main.cpp:64:13: note: in expansion of macro ‘rep’
  rep(i,maxC)rep(j,maxC)c[i][j]=-1;
             ^~~

ソースコード

diff #

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>

#include <algorithm>
#include <cmath>

#include <string>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>

/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
const LL mod = (LL)1e9;
const int maxC = 10000;
LL c[maxC][maxC/2];

LL ccc(LL n,LL k){
	LL ans;
	LL kk = min(k,n-k);
	if(n<maxC && kk < maxC && c[n][kk] != -1){
		ans = c[n][kk];
	}
	else if(kk ==0 ){
		if(n<maxC){
			c[n][kk] = 1;
		}
		ans = 1;
	}else if( kk==1){
		if(n<maxC){
			c[n][kk] = n%mod;
		}
		ans = n%mod;
	}
	else{
		ans = (ccc(n-1,kk-1)%mod+ccc(n-1,kk)%mod)%mod;
		if(n<maxC && kk < maxC){
			c[n][kk] = ans;
		}
	}
	return ans;
}
int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(6);//
    
	LL N,M;
	cin>>N>>M;
	LL ama = (N%(M*1000))/1000;
	rep(i,maxC)rep(j,maxC)c[i][j]=-1;
	//N C ama
	P(ccc(M,ama));
    return 0;
}
0