結果
問題 | No.546 オンリー・ワン |
ユーザー |
![]() |
提出日時 | 2018-10-28 18:10:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 860 bytes |
コンパイル時間 | 712 ms |
コンパイル使用メモリ | 82,656 KB |
実行使用メモリ | 13,640 KB |
最終ジャッジ日時 | 2024-11-19 07:12:17 |
合計ジャッジ時間 | 10,284 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 2 WA * 2 TLE * 3 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <cstdio> #include <cstring> #include <string> #include <math.h> using namespace std; typedef long long ll; typedef double D; typedef pair<int,int> P; #define M 1000000007 #define F first #define S second #define PB push_back #define INF 100000000000000000 ll n,l,r,a[15]; ll gcd(ll x,ll y){ if(x<y)swap(x,y); if(x%y==0)return y; return gcd(y,x%y); } ll lca(ll x,ll y){ return x*y/gcd(x,y); } ll sum(ll x){ ll res=0; for(int k=1;k<1<<n;k++){ ll p=1,c=0; for(int i=0;i<n;i++){ if(k>>i&1){ p=lca(p,a[i]); c++; } } if(c==1)res+=x/p; else if(c%2)res+=(x/p)*2; else res-=(x/p)*2; } return res; } int main(void){ cin>>n>>l>>r; for(int i=0;i<n;i++)cin>>a[i]; cout<<sum(r)-sum(l-1)<<endl; }