結果

問題 No.129 お年玉(2)
ユーザー hotpepsihotpepsi
提出日時 2015-01-24 01:31:21
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 582 bytes
コンパイル時間 585 ms
コンパイル使用メモリ 59,996 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-23 01:11:53
合計ジャッジ時間 1,983 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 4 WA * 42
権限があれば一括ダウンロードができます

ソースコード

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 = 1;
	for (LL i = 1; i <= N; ++i) {
		a = (a * i) % MOD;
	}
	LL ans = 1;
	for (LL i = M-N+1; i <= M; ++i) {
		LL b = gcd(a, i);
		a /= b;
		ans = (ans * (i / b)) % MOD;
	}
	cout << ans << endl;
	return 0;
}
0