結果

問題 No.546 オンリー・ワン
ユーザー furafura
提出日時 2020-07-25 02:54:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 2,101 ms
コンパイル使用メモリ 200,448 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 10:54:03
合計ジャッジ時間 2,753 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

inline int popcount(int x){
	x=((x>>1)&0x55555555)+(x&0x55555555);
	x=((x>>2)&0x33333333)+(x&0x33333333);
	x=((x>>4)+x)&0x0f0f0f0f;
	x+=(x>>8);
	x+=(x>>16);
	return x&0x3f;
}

int main(){
	int choose[11][11]={};
	rep(i,11) choose[i][0]=1;
	rep(i,10) rep(j,i+1) choose[i+1][j+1]=choose[i][j]+choose[i][j+1];

	int n,l,r; scanf("%d%d%d",&n,&l,&r);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	int coef[11];
	for(int i=2;i<=10;i++){
		coef[i]=i;
		for(int j=2;j<i;j++) coef[i]-=choose[n][j]*coef[j];
	}

	int ans=0;
	rep(S,1<<n) if(S!=0) {
		int L=1;
		rep(i,n) if(S>>i&1) L=lcm(L,a[i]);
		int pc=popcount(S);
		if(pc==1){
			ans+=r/L-(l-1)/L;
		}
		else{
			ans-=coef[pc]*(r/L-(l-1)/L);
		}
	}
	printf("%d\n",ans);

	return 0;
}
0