4 条题解
-
1
This question isn't difficult, but it's tricky
First, we observe that for each input , we can break it down bit by bit. If a binary bit is , we can mark it, indicating that this bit can be selected
Then we examine the feed. If a certain feed's corresponding bit does not appear in the original animal, it means that to raise an animal with that bit set to , this feed is necessary. Therefore, this bit must be , which for the answer translates to dividing by . Expressed in the form of , this means
The final answer, since it asks how many more pets can be kept, is
If you fail, see See Everyone
#include<iostream> #include<cstdio> #include<cmath> #define int long long using namespace std; bool Test_MLE_start; constexpr int N=105; int _=1,n,m,c,k; __int128 ans; bool bit[N],ton[N]; inline int reads(){ char c=getchar(); int x=0,f=1; while(!isdigit(c)){if(c=='-') f=-1;c=getchar();} while(isdigit(c)){x=(x<<3)+(x<<1)+(c^'0');c=getchar();} return x*f; } inline void files(){ freopen("zoo.in","r",stdin); freopen("zoo.out","w",stdout); } void writes(int x){ if(x>9) writes(x/10); putchar(x%10+'0'); } inline void clr(){ // Don't forget! } bool Test_MLE_end; signed main(){ // printf("%lf Mb\n",(&Test_MLE_end-&Test_MLE_start-1)/1024.0/1024.0); // files(); // _=reads(); while(_--){ clr();n=reads(),m=reads(),c=reads(),k=reads(),ans=(1<<k); for(int i=1;i<=n;i++){ int t=reads(),cnt=0; while(t){ if(t&1) bit[cnt]=1; t>>=1,cnt++; } }for(int i=1;i<=m;i++){ int p=reads(),q=reads(); if(!bit[p]&&!ton[p]) k--,ton[p]=1; } if(k==64&&!n) puts("18446744073709551616"); else if(k==64&&n) puts("18446744073709551615"); else cout<<(unsigned long long)pow(2,k)-n<<"\n"; } return 0; } -
1
這道題不難,但是坑
首先我們發現就是說輸入的每個 中將其拆位,只要該二進位位為 ,則可以打一個標記,表示這一位可以選
接著我們再看飼料,如果某一個飼料對應的位置沒有在原本的動物中出現,表示若想飼養該位為 的動物必須有這種飼料,因此這一位必須是 ,對答案來說就是除以 ,寫成 的形式就是讓
最後答案因為是還可以養多少寵物,則答案為
如果你沒過,詳見見任何人
#include<iostream> #include<cstdio> #include<cmath> #define int long long using namespace std; bool Test_MLE_start; constexpr int N=105; int _=1,n,m,c,k; __int128 ans; bool bit[N],ton[N]; inline int reads(){ char c=getchar(); int x=0,f=1; while(!isdigit(c)){if(c=='-') f=-1;c=getchar();} while(isdigit(c)){x=(x<<3)+(x<<1)+(c^'0');c=getchar();} return x*f; } inline void files(){ freopen("zoo.in","r",stdin); freopen("zoo.out","w",stdout); } void writes(int x){ if(x>9) writes(x/10); putchar(x%10+'0'); } inline void clr(){ // Don't forget! } bool Test_MLE_end; signed main(){ // printf("%lf Mb\n",(&Test_MLE_end-&Test_MLE_start-1)/1024.0/1024.0); // files(); // _=reads(); while(_--){ clr();n=reads(),m=reads(),c=reads(),k=reads(),ans=(1<<k); for(int i=1;i<=n;i++){ int t=reads(),cnt=0; while(t){ if(t&1) bit[cnt]=1; t>>=1,cnt++; } }for(int i=1;i<=m;i++){ int p=reads(),q=reads(); if(!bit[p]&&!ton[p]) k--,ton[p]=1; } if(k==64&&!n) puts("18446744073709551616"); else if(k==64&&n) puts("18446744073709551615"); else cout<<(unsigned long long)pow(2,k)-n<<"\n"; } return 0; } -
1
这道题不难,但是坑
首先我们发现就是说输入的每一个 中将其拆位,只要该二进制位为 ,则可以打一个标记,表示这一位可以选
然后我们再看饲料,如果某一个饲料对应的位没有在原来的动物中出现,说明如果想要饲养该位为 的动物必须有这种饲料,所以这一位必须是 ,这对于答案来说就是除以 ,写成 的形式就是让
最后答案因为是还可以养多少宠物,则答案为
如果你没过,详见见任何人
#include<iostream> #include<cstdio> #include<cmath> #define int long long using namespace std; bool Test_MLE_start; constexpr int N=105; int _=1,n,m,c,k; __int128 ans; bool bit[N],ton[N]; inline int reads(){ char c=getchar(); int x=0,f=1; while(!isdigit(c)){if(c=='-') f=-1;c=getchar();} while(isdigit(c)){x=(x<<3)+(x<<1)+(c^'0');c=getchar();} return x*f; } inline void files(){ freopen("zoo.in","r",stdin); freopen("zoo.out","w",stdout); } void writes(int x){ if(x>9) writes(x/10); putchar(x%10+'0'); } inline void clr(){ // Don't forget! } bool Test_MLE_end; signed main(){ // printf("%lf Mb\n",(&Test_MLE_end-&Test_MLE_start-1)/1024.0/1024.0); // files(); // _=reads(); while(_--){ clr();n=reads(),m=reads(),c=reads(),k=reads(),ans=(1<<k); for(int i=1;i<=n;i++){ int t=reads(),cnt=0; while(t){ if(t&1) bit[cnt]=1; t>>=1,cnt++; } }for(int i=1;i<=m;i++){ int p=reads(),q=reads(); if(!bit[p]&&!ton[p]) k--,ton[p]=1; } if(k==64&&!n) puts("18446744073709551616"); else if(k==64&&n) puts("18446744073709551615"); else cout<<(unsigned long long)pow(2,k)-n<<"\n"; } return 0; } -
-1
-
如果这一位没有要求,可以随意放
-
如果这一位有要求但存在 这一位是 ,也可以随意放
统计满足条件的位数 ,答案就是 。
注意到 ,用
unsigned long long也存不下,可以使用long double存。最后
cout<<fixed<<setprecision(0)<<ans;即可避免科学计数法的问题。#include<bits/stdc++.h> #define R(x) x=read() #define int long long using namespace std; inline int read() { int x=0,y=1; char e=getchar(); while(e<'0'||e>'9') { if(e=='-')y=-1; e=getchar(); } while(e>='0'&&e<='9') { x=(x<<1)+(x<<3)+(e-'0'); e=getchar(); } return x*y; } int n,m,c,k,cnt; bool vis[70],xx[70]; signed main() { freopen("zoo.in","r",stdin); freopen("zoo.out","w",stdout); R(n),R(m),R(c),R(k); for(int i=1; i<=n; ++i) { int R(x),j=0; while(x) { if(x&1)vis[j]=1; ++j; x>>=1; } } while(m--) { int R(p),R(q); xx[p]=1; } for(int i=0; i<k; ++i) if(!xx[i]||(xx[i]&&vis[i]))++cnt; long double ans=1; for(int i=1; i<=cnt; ++i) ans*=2; cout<<fixed<<setprecision(0)<<ans-n<<"\n"; return 0; } -
- 1
信息
- ID
- 463
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- (无)
- 递交数
- 34
- 已通过
- 5
- 上传者