結果

問題 No.2120 場合の数の下8桁
ユーザー kotatsugamekotatsugame
提出日時 2022-11-04 21:47:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 621 ms
コンパイル使用メモリ 75,376 KB
実行使用メモリ 23,036 KB
最終ジャッジ日時 2023-09-26 00:08:29
合計ジャッジ時間 3,897 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
21,344 KB
testcase_01 AC 100 ms
19,604 KB
testcase_02 AC 94 ms
20,452 KB
testcase_03 AC 98 ms
21,032 KB
testcase_04 AC 94 ms
20,468 KB
testcase_05 AC 94 ms
21,212 KB
testcase_06 AC 98 ms
20,764 KB
testcase_07 AC 93 ms
20,860 KB
testcase_08 AC 95 ms
20,016 KB
testcase_09 AC 105 ms
20,812 KB
testcase_10 AC 97 ms
21,964 KB
testcase_11 AC 109 ms
20,076 KB
testcase_12 AC 103 ms
19,756 KB
testcase_13 AC 95 ms
20,812 KB
testcase_14 AC 98 ms
23,036 KB
testcase_15 AC 101 ms
21,364 KB
testcase_16 AC 110 ms
21,148 KB
testcase_17 AC 98 ms
19,436 KB
testcase_18 AC 110 ms
21,996 KB
testcase_19 AC 101 ms
21,164 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:21:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   21 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<vector>
using namespace std;
const int LIM=1e7;
bool isp[LIM+1];
vector<int>ps;
vector<int>val;
void f(int N,int coef)
{
	for(int i=0;i<ps.size();i++)
	{
		int n=N,c=0;
		while(n>=ps[i])
		{
			c+=n/=ps[i];
		}
		val[i]+=c*coef;
	}
}
main()
{
	for(int i=2;i<=LIM;i++)if(!isp[i])
	{
		ps.push_back(i);
		val.push_back(0);
		for(int j=i+i;j<=LIM;j+=i)isp[j]=true;
	}
	int M,N;cin>>M>>N;
	f(M,1);
	f(N,-1);
	f(M-N,-1);
	long long ans=M>=N;
	for(int i=0;i<ps.size();i++)
	{
		for(int j=0;j<val[i];j++)ans=ans*ps[i]%(int)1e8;
	}
	cout<<setw(8)<<setfill('0')<<ans<<endl;
}
0