Submission #69346434
Source Code Expand
//# pragma GCC target("avx2")
# pragma GCC optimize("O3")
# pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include"atcoder/all"
using namespace atcoder;
typedef modint998244353 mi;
using namespace std;
#define all(a) a.begin(),a.end()
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
#define compress(a) sort(all(a));a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
constexpr ll mod=1000000007;
constexpr ll inf=3e18;
ll gcd(ll a,ll b){
if(!b)return a;
return gcd(b,a%b);
}
ll lcm(ll a,ll b){
ll g=gcd(a,b);
a/=g;
b/=g;
if(log10(a)+log10(b)+log10(g)>18.1)return -1;
else return a*b*g;
}
ll binom[22][22];
int main(){
ll n,m,y;
cin>>n>>m>>y;
vector<ll>a(n);
rep(i,n)cin>>a[i];
ll sum=0;
vector<ll>subset(1<<n);
rep(i,1<<n){
ll L=1;
rep(j,n){
if(L==-1)break;
if(i&(1<<j)){
L=lcm(L,a[j]);
}
}
if(L!=-1){
subset[i]=y/L;
}
}
binom[0][0]=1;
rep(i,20){
rep(j,i+1){
binom[i+1][j]+=binom[i][j];
binom[i+1][j+1]+=binom[i][j];
}
}
vector<ll>ptn(n+1);
rep(i,n+1){
if(i==m)ptn[i]=1;
else if(i>m){
ll sum=0;
for(int j=m;j<i;j++){
sum-=binom[i][j]*ptn[j];
}
ptn[i]=sum;
}
//cout<<ptn[i]<<endl;
}
ll ans=0;
rep(i,1<<n){
ans+=subset[i]*ptn[__builtin_popcount(i)];
}
cout<<ans<<endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | F - Loud Cicada |
| User | Rho17 |
| Language | C++ 20 (gcc 12.2) |
| Score | 525 |
| Code Size | 1578 Byte |
| Status | AC |
| Exec Time | 578 ms |
| Memory | 11440 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:39:12: warning: unused variable ‘sum’ [-Wunused-variable]
39 | ll sum=0;
| ^~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 525 / 525 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt |
| All | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt, 01-34.txt, 01-35.txt, 01-36.txt, 01-37.txt, 01-38.txt, 01-39.txt, 01-40.txt, 01-41.txt, 01-42.txt, 01-43.txt, 01-44.txt, 01-45.txt, 01-46.txt, 01-47.txt, 01-48.txt, 01-49.txt, 01-50.txt, 01-51.txt, 01-52.txt, 01-53.txt, 01-54.txt, 01-55.txt, 01-56.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-01.txt | AC | 1 ms | 3760 KiB |
| 00-sample-02.txt | AC | 1 ms | 3800 KiB |
| 00-sample-03.txt | AC | 386 ms | 11388 KiB |
| 01-01.txt | AC | 1 ms | 3884 KiB |
| 01-02.txt | AC | 1 ms | 3732 KiB |
| 01-03.txt | AC | 1 ms | 3840 KiB |
| 01-04.txt | AC | 1 ms | 3716 KiB |
| 01-05.txt | AC | 1 ms | 3708 KiB |
| 01-06.txt | AC | 1 ms | 3796 KiB |
| 01-07.txt | AC | 1 ms | 3764 KiB |
| 01-08.txt | AC | 1 ms | 3688 KiB |
| 01-09.txt | AC | 1 ms | 3712 KiB |
| 01-10.txt | AC | 1 ms | 3768 KiB |
| 01-11.txt | AC | 1 ms | 3776 KiB |
| 01-12.txt | AC | 1 ms | 3688 KiB |
| 01-13.txt | AC | 1 ms | 3684 KiB |
| 01-14.txt | AC | 1 ms | 3748 KiB |
| 01-15.txt | AC | 578 ms | 11216 KiB |
| 01-16.txt | AC | 574 ms | 11392 KiB |
| 01-17.txt | AC | 562 ms | 11332 KiB |
| 01-18.txt | AC | 483 ms | 11388 KiB |
| 01-19.txt | AC | 492 ms | 11388 KiB |
| 01-20.txt | AC | 452 ms | 11340 KiB |
| 01-21.txt | AC | 1 ms | 3840 KiB |
| 01-22.txt | AC | 1 ms | 3724 KiB |
| 01-23.txt | AC | 1 ms | 3780 KiB |
| 01-24.txt | AC | 1 ms | 3836 KiB |
| 01-25.txt | AC | 117 ms | 5368 KiB |
| 01-26.txt | AC | 1 ms | 3800 KiB |
| 01-27.txt | AC | 1 ms | 3928 KiB |
| 01-28.txt | AC | 1 ms | 3684 KiB |
| 01-29.txt | AC | 46 ms | 5340 KiB |
| 01-30.txt | AC | 1 ms | 3928 KiB |
| 01-31.txt | AC | 1 ms | 3932 KiB |
| 01-32.txt | AC | 1 ms | 3780 KiB |
| 01-33.txt | AC | 274 ms | 11396 KiB |
| 01-34.txt | AC | 387 ms | 11440 KiB |
| 01-35.txt | AC | 230 ms | 11428 KiB |
| 01-36.txt | AC | 424 ms | 11440 KiB |
| 01-37.txt | AC | 7 ms | 3872 KiB |
| 01-38.txt | AC | 14 ms | 3872 KiB |
| 01-39.txt | AC | 572 ms | 11328 KiB |
| 01-40.txt | AC | 573 ms | 11308 KiB |
| 01-41.txt | AC | 573 ms | 11436 KiB |
| 01-42.txt | AC | 573 ms | 11384 KiB |
| 01-43.txt | AC | 573 ms | 11216 KiB |
| 01-44.txt | AC | 256 ms | 11388 KiB |
| 01-45.txt | AC | 258 ms | 11328 KiB |
| 01-46.txt | AC | 530 ms | 11328 KiB |
| 01-47.txt | AC | 515 ms | 11308 KiB |
| 01-48.txt | AC | 518 ms | 11312 KiB |
| 01-49.txt | AC | 518 ms | 11388 KiB |
| 01-50.txt | AC | 6 ms | 3712 KiB |
| 01-51.txt | AC | 1 ms | 3840 KiB |
| 01-52.txt | AC | 424 ms | 11312 KiB |
| 01-53.txt | AC | 423 ms | 11216 KiB |
| 01-54.txt | AC | 423 ms | 11400 KiB |
| 01-55.txt | AC | 423 ms | 11324 KiB |
| 01-56.txt | AC | 424 ms | 11392 KiB |