結果
| 問題 | No.546 オンリー・ワン |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-20 11:09:13 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 1,064 bytes |
| 記録 | |
| コンパイル時間 | 1,502 ms |
| コンパイル使用メモリ | 212,288 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-21 04:03:46 |
| 合計ジャッジ時間 | 2,432 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 |
コンパイルメッセージ
main.cpp:23:43: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' [-Wc++20-extensions]
23 | void dfs(ll idx, ll num, ll val, ll& ans, auto& C){
| ^~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define MOD(a, m) ((a % m + m) % m)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;
ll N, L, H;
ll lcd(ll a, ll b){
ll g = gcd(a, b);
return g * a/g * b/g;
}
void dfs(ll idx, ll num, ll val, ll& ans, auto& C){
if(idx == N){
if(num == 0) return;
ll x = H/val - (L-1)/val;
if(num % 2) ans += num*x;
else ans -= num*x;
return;
}
dfs(idx+1, num, val, ans, C);
dfs(idx+1, num+1, lcd(val, C[idx]), ans, C);
}
int main(){
cin >> N >> L >> H;
vector<ll> C(N);
for(auto& c : C)
cin >> c;
ll ans = 0;
dfs(0, 0, 1, ans, C);
cout << ans << endl;
return 0;
}