結果
| 問題 | No.546 オンリー・ワン |
| コンテスト | |
| ユーザー |
hiyokko2
|
| 提出日時 | 2017-07-15 00:08:20 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 902 bytes |
| コンパイル時間 | 1,347 ms |
| コンパイル使用メモリ | 157,408 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-08 00:17:18 |
| 合計ジャッジ時間 | 1,930 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 3 |
| other | AC * 1 WA * 6 |
ソースコード
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;
int N, L, H;
int C[15];
int gcd(int a, int b)
{
if (b == 0) return a;
return gcd(b, a % b);
}
int lcm(int a, int b)
{
return a / gcd(a, b) * b;
}
int nA(int A)
{
return H / A - (L - 1) / A;
}
int sum = 0;
void rec(int i, int cnt, int tLcm)
{
if (i == N) {
if (cnt % 2 == 0) {
sum -= nA(tLcm);
} else {
sum += nA(tLcm);
}
return;
}
rec(i + 1, cnt + 1, lcm(tLcm, C[i]));
rec(i + 1, cnt, tLcm);
}
signed main()
{
cin >> N >> L >> H;
REP(i,N) cin >> C[i];
//cout << nA(5) << endl;
/*
REP(i,N) {
sum += nA(C[i]);
}
*/
rec(0, 1, 1);
cout << sum << endl;
}
hiyokko2