結果
| 問題 | No.546 オンリー・ワン |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-25 02:54:46 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 821 bytes |
| 記録 | |
| コンパイル時間 | 1,999 ms |
| コンパイル使用メモリ | 195,844 KB |
| 最終ジャッジ日時 | 2025-01-12 05:13:31 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 2 WA * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | int n,l,r; scanf("%d%d%d",&n,&l,&r);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:23:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
23 | rep(i,n) scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#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;
}