結果
| 問題 | No.546 オンリー・ワン |
| コンテスト | |
| ユーザー |
ゆにぽけ
|
| 提出日時 | 2023-10-26 08:41:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,009 bytes |
| 記録 | |
| コンパイル時間 | 1,268 ms |
| コンパイル使用メモリ | 122,536 KB |
| 最終ジャッジ日時 | 2025-02-17 13:48:16 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 5 WA * 2 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cmath>
#include<ctime>
#include<iomanip>
#include<numeric>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<random>
#include<functional>
#include<utility>
using namespace std;
long long gcd(long long a,long long b)
{
while(b)
{
a %= b;
swap(a,b);
}
return a;
}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}
int N,L,H;
long long C[10];
void solve()
{
cin >> N >> L >> H;
for(int i = 0;i < N;i++) cin >> C[i];
long long ans = 0;
for(int i = 1;i < 1 << N;i++)
{
long long l = 1;
for(int j = 0;j < N;j++) if(i >> j & 1) l = lcm(l,C[j]);
int b = __builtin_popcount(i);
long long cur = (H/l - (L+l-1)/l + 1)*b;
if(b & 1) ans += cur;
else ans -= cur;
}
cout << ans << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tt = 1;
//cin >> tt;
while(tt--) solve();
}
ゆにぽけ