結果
| 問題 | No.546 オンリー・ワン |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-22 10:16:15 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 925 bytes |
| 記録 | |
| コンパイル時間 | 981 ms |
| コンパイル使用メモリ | 201,052 KB |
| 最終ジャッジ日時 | 2026-07-13 10:47:46 |
| 合計ジャッジ時間 | 1,597 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/stl_algobase.h:76,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/algorithm:62,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bit: In instantiation of 'constexpr int std::__popcount(_Tp) [with _Tp = int]':
main.cpp:33:27: required from here
33 | int p = __popcount(i);
| ~~~~~~~~~~^~~
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bit:308:34: error: argument 1 in call to function '__builtin_popcountg' has signed type
308 | return __builtin_popcountg(__x);
| ^~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
template<typename T>
void FastMobius(vector<T> &A){
int n = A.size();
for(int i=1; i<n; i<<=1){
for(int k=0; k<n; k++){
if(i&k) A.at(k) -= A.at(k-i);
else k += i-1;
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
long long N,L,R; cin >> N >> L >> R;
vector<long long> C(N);
for(auto &c : C) cin >> c;
int n2 = 1<<N;
vector<long long> LCM(n2,1);
for(int i=1; i<n2; i++) for(int k=0; k<N; k++) if(i&(1<<k)){
long long lcm = LCM.at(i-(1<<k));
LCM.at(i) = lcm*C.at(k)/gcd(lcm,C.at(k));
}
long long answer = 0,inf = 1001001001;
for(int i=1; i<n2; i++){
long long lcm = LCM.at(i);
int p = __popcount(i);
if(p%2) answer += (R/lcm-(L-1)/lcm)*p;
else answer -= (R/lcm-(L-1)/lcm)*p;
}
cout << answer << endl;
}