結果

問題 No.546 オンリー・ワン
ユーザー snrnsidysnrnsidy
提出日時 2021-09-28 12:29:18
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,431 bytes
コンパイル時間 7,115 ms
コンパイル使用メモリ 244,664 KB
最終ジャッジ日時 2025-01-24 18:38:01
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:84,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/numeric: In instantiation of 'constexpr std::common_type_t<_Tp1, _Tp2> std::gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = long long int; common_type_t<_Tp1, _Tp2> = __int128]':
main.cpp:42:33:   required from here
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/numeric:166:21: error: static assertion failed: std::gcd arguments must be integers
  166 |       static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
      |                     ^~~~~~~~~~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/numeric:166:21: note: 'std::is_integral_v<__int128>' evaluates to false
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_pair.h:60,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_algobase.h:64,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/specfun.h:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/cmath:1935,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:41:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/type_traits: In instantiation of 'struct std::make_unsigned<__int128>':
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/type_traits:2003:11:   required by substitution of 'template<class _Tp> using make_unsigned_t = typename std::make_unsigned::type [with _Tp = __int128]'
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/numeric:173:24:   required from 'constexpr std::common_type_t<_Tp1, _Tp2> std::gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = long long int; common_type_t<_Tp1, _Tp2> = __int128]'
main.cpp:42:33:   required from here
/home/l

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
long long int arr[10];
__int128 gcd(__int128 a,__int128 b)
{
if(b==0)
{
return a;
}
return gcd(b,a%b);
}
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
long long int n,l,r,t;
long long int res = 0;
vector <long long int> v;
cin >> n >> l >> r;
for(int i=0;i<n;i++)
{
cin >> t;
v.push_back(t);
}
for(int i=1;i<(1<<n);i++)
{
__int128 val = 1;
int cnt = 0;
bool big = false;
for(int j=0;j<n;j++)
{
if((i&(1<<j)))
{
__int128 g = gcd(val,v[j]);
if(val*v[j] > r*g)
{
big = true;
break;
}
val*=v[j];
val/=g;
cnt++;
}
}
if(big) continue;
long long int way = r/val;
way -= (l-1)/val;
//cout << i << ' ' << (long long int)(val) << ' ' << way << '\n';
if(cnt%2==1)
{
for(int j=0;j<n;j++)
{
if((i&(1<<j))) arr[j]+=way;
}
}
else
{
for(int j=0;j<n;j++)
{
if((i&(1<<j))) arr[j]-=way;
}
}
}
for(int i=0;i<n;i++) res += arr[i];
cout << res << '\n';
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0