牛客2021年愚人节比赛 【题解】
生活随笔
收集整理的這篇文章主要介紹了
牛客2021年愚人节比赛 【题解】
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
很有意思的一套題,難度不大,不過題目很有意思。
比賽鏈接:https://ac.nowcoder.com/acm/contest/12800
目錄
- A: 出愚人節歡樂賽
- B: 你這題,狗屁不通
- C: 遷躍據數
- D: qcjj的蝴蝶結1
- E: qcjj的蝴蝶結2
- F: qcjj背貫口
- G: 詭異的七重咒印
- H: 氵林女女的記錄本
- I: 數據躍遷
A: 出愚人節歡樂賽
只要代碼沒有編譯錯誤都可以過,沒有輸出也可以過。
B: 你這題,狗屁不通
這道題考察的就是如何獲取當前的時間并輸出用到了一個_TIME_
#include<bits/stdc++.h> using namespace std; int main(void) {cout<<"2021/05/27 "<<__TIME__<<endl;return 0; }C: 遷躍據數
這道題和數據躍遷這道題是配套的。
我們需要通過數據躍遷來分析出這道題的結果。
同過二分來排除,如果TLE說明結果在另一部分,以此來找答案。
最后會發現結果是866,通過哈希值求其原字符串。
D: qcjj的蝴蝶結1
水題
#include<bits/stdc++.h> using namespace std; int main(void) {int t; cin>>t;while(t--){int n; cin>>n;int ans=0;int a;for(int i=1;i<=n;i++){scanf("%d",&a);if(a%2) ans++;}cout<<ans<<endl;}return 0; }E: qcjj的蝴蝶結2
暴力:枚舉將其全部轉換為每一種所需的花費,在其中取一個min就可以了。
#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> using namespace std; const int N=110; int a[N]; int t,n,m; int w[N][N]; int main(void) {cin>>t;while(t--){memset(w,-1,sizeof w);cin>>n;for(int i=1;i<=n;i++) cin>>a[i];cin>>m;for(int i=1;i<=m;i++) {int x,y,z; cin>>x>>y>>z;w[x][y]=z;}long long int ans=1e18;for(int i=1;i<=n;i++){long long int sum=0;bool flag=true;for(int j=1;j<=n;j++){if(i==j) continue;//自己染成自己的情況if(w[j][i]==-1)//沒有這種染色劑的情況{flag=false;break;}sum+=(long long int)a[j]*w[j][i];}if(flag) ans=min(ans,sum);}if(n==0) cout<<0<<endl;else if(ans==1e18) cout<<"qcjj yyds"<<endl;else cout<<ans<<endl;}return 0; }F: qcjj背貫口
劉備 關羽 張飛 趙云 徐庶 曹操 夏侯惇 顏良 8 馬 龍 白龍馬 白馬 豹 虎 蛇 萬里煙云獸 8 #include<bits/stdc++.h> using namespace std; int main(void) {cout<<8<<endl;cout<<8<<endl;cout<<16<<endl;return 0; }G: 詭異的七重咒印
#include<bits/stdc++.h> using namespace std; const int mod=1000000007; typedef long long int LL; LL n; LL quick_pow(LL a,LL b,int c) {LL res=1;while(b){if(b&1) res=res*a%c;a=a*a%c;b=b>>1;}return res%c; } int main() {scanf("%lld",&n);printf("%lld\n",n%mod);printf("%lld\n",(2*n-1)%mod);printf("%lld\n",(n%mod)*(n%mod)%mod);printf("%lld\n",quick_pow(2,n-1,mod));printf("%lld\n",quick_pow(2,quick_pow(2,n-1,mod-1),mod));printf(n&1?"1\n":"2\n");printf("%lld\n",(quick_pow(10,n,mod)-1)*quick_pow(9,mod-2,mod)%mod); }H: 氵林女女的記錄本
1.許嵩 降溫 281
2. 陳奕迅 第二次工業革命時期是19世紀中期,搜一下符合的只有 1874
3. 高曉松寫給李宗盛的越過山丘歌詞這個不是原歌詞 20
4. 那英 王菲 1998
5. 周杰倫 發如雪 3000
I: 數據躍遷
通過C題來判斷答案,還是用二分的方法,用一個死循環,來判斷到底在哪一個區間。
#include<cstdio> #include<iostream> #include<string> using namespace std; int main(void) {cout<<514<<endl;return 0; } 《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的牛客2021年愚人节比赛 【题解】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Acwing 第 2场热身赛 【完结】
- 下一篇: 乘法逆元通俗易懂的理解方法