結果

問題 No.129 お年玉(2)
ユーザー rodea
提出日時 2018-03-01 15:18:18
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 400 bytes
コンパイル時間 618 ms
コンパイル使用メモリ 67,672 KB
実行使用メモリ 13,636 KB
最終ジャッジ日時 2024-12-25 11:31:17
合計ジャッジ時間 260,995 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 4 TLE * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;

int combination(int m, int i)
{
	if (i == 0 || i == m) return 1;
	if (i == 1) return m;
	return combination(m - 1, i - 1) + combination(m - 1, i);
}


int main()
{
	int n, m;

	cin >> n >> m;

	while (n >= m * 1000) n -= m * 1000;
		
	int i = 0;
	while (n >= 1000)
	{
		n -= 1000;
		i++;
	}

	cout << combination(m, min(i, m-i)) << endl;
}
0