結果

問題 No.129 お年玉(2)
ユーザー hotpepsihotpepsi
提出日時 2015-01-24 01:33:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,528 ms / 5,000 ms
コード長 641 bytes
コンパイル時間 700 ms
コンパイル使用メモリ 59,732 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 22:16:48
合計ジャッジ時間 38,594 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
5,248 KB
testcase_01 AC 3,528 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1,166 ms
5,376 KB
testcase_06 AC 578 ms
5,376 KB
testcase_07 AC 1,409 ms
5,376 KB
testcase_08 AC 1,701 ms
5,376 KB
testcase_09 AC 413 ms
5,376 KB
testcase_10 AC 1,765 ms
5,376 KB
testcase_11 AC 754 ms
5,376 KB
testcase_12 AC 12 ms
5,376 KB
testcase_13 AC 6 ms
5,376 KB
testcase_14 AC 557 ms
5,376 KB
testcase_15 AC 500 ms
5,376 KB
testcase_16 AC 807 ms
5,376 KB
testcase_17 AC 296 ms
5,376 KB
testcase_18 AC 1,504 ms
5,376 KB
testcase_19 AC 2,308 ms
5,376 KB
testcase_20 AC 1,035 ms
5,376 KB
testcase_21 AC 368 ms
5,376 KB
testcase_22 AC 949 ms
5,376 KB
testcase_23 AC 1,640 ms
5,376 KB
testcase_24 AC 2,689 ms
5,376 KB
testcase_25 AC 769 ms
5,376 KB
testcase_26 AC 1,274 ms
5,376 KB
testcase_27 AC 1,141 ms
5,376 KB
testcase_28 AC 926 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 3 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 5 ms
5,376 KB
testcase_37 AC 3 ms
5,376 KB
testcase_38 AC 100 ms
5,376 KB
testcase_39 AC 72 ms
5,376 KB
testcase_40 AC 200 ms
5,376 KB
testcase_41 AC 475 ms
5,376 KB
testcase_42 AC 219 ms
5,376 KB
testcase_43 AC 13 ms
5,376 KB
testcase_44 AC 2,855 ms
5,376 KB
testcase_45 AC 122 ms
5,376 KB
testcase_46 AC 15 ms
5,376 KB
testcase_47 AC 2,270 ms
5,376 KB
testcase_48 AC 1,729 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>

using namespace std;

#define MOD 1000000000LL
typedef long long LL;

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }

int main(int argc, char *argv[])
{
	string s;
	getline(cin, s);
	LL N, M;
	stringstream ss(s);
	ss >> N;
	getline(cin, s);
	M = atoi(s.c_str());
	N /= 1000;
	N %= M;
	LL a[10000] = {};
	for (LL i = 0; i < N; ++i) {
		a[i] = i + 1;
	}
	LL ans = 1;
	for (LL i = M-N+1; i <= M; ++i) {
		LL b = i;
		for (LL j = 0; j < N; ++j) {
			LL g = gcd(a[j], b);
			a[j] /= g, b /= g;
		}
		ans = (ans * b) % MOD;
	}
	cout << ans << endl;
	return 0;
}
0