Educational Codeforces Round 107 (Rated for Div. 2)
生活随笔
收集整理的這篇文章主要介紹了
Educational Codeforces Round 107 (Rated for Div. 2)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Educational Codeforces Round 107 (Rated for Div. 2)
| A | Review Site | 簽到 |
| B | GCD Length | 思維+構造 |
| C | Yet Another Card Deck | 思維 |
| D | Min Cost String | 構造題 |
| E | Colorings and Dominoes | 思維題,構造題 |
| F | Chainword | |
| G | Chips on a Board |
A
題意:
有3種評論員,第一個會給電影贊,第二個會給電影踩,第三個如果當前踩的數量大于贊,就會給贊,否則給踩
現在有n個評論員,問贊最多是多少
題解:
把贊的評論員全部放前面,第三種放中間,踩的最后
贊的數量+中立-踩
代碼:
#include<bits/stdc++.h> typedef long long ll; using namespace std; inline int read(){int s=0,w=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();//s=(s<<3)+(s<<1)+(ch^48);return s*w; } const int maxn=60; int a[maxn]; int main() {int t;cin>>t;while(t--){int n;cin>>n;int sum=0; int tot=0;for(int i=1;i<=n;i++){int x;cin>>x;if(x==1||x==3){sum++;}}cout<<sum<<endl;}return 0; } /* 反對>贊同 × 贊同>=反對 4 1 2 3 1 2 3 5 1 1 1 1 1 3 3 3 2*/C
題意:
一個序列,每次給出一個x,輸出第一個出現x的坐標,并將其放到最前面,其他數順位,有q個這樣的操作
題解:
雖然數會有重復,但是只需要記錄第一個出現的就行,后面出現的沒影響,然后用數組模擬過程即可
a和t的范圍很小,直接暴力就行
代碼:
#include<bits/stdc++.h> typedef long long ll; using namespace std; inline int read(){int s=0,w=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();//s=(s<<3)+(s<<1)+(ch^48);return s*w; } const int maxn=800; int b[maxn]; int v[maxn]; int main() {int n,q;cin>>n>>q;int tot=0;for(int i=1;i<=n;i++){int x;cin>>x;if(b[x]!=0)continue;v[++tot]=x;//順序存數 b[x]=i;//x的位置 }int x;for(int i=1;i<=q;i++){ cin>>x;cout<<b[x]<<" ";int pos;for(int i=1;i<=tot;i++){if(v[i]==x){pos=i;break;}}for(int i=1;i<pos;i++){b[v[i]]++;}for(int i=pos;i>=2;i--){v[i]=v[i-1];//往后移動一次 }b[x]=1;v[1]=x;}return 0; }總結
以上是生活随笔為你收集整理的Educational Codeforces Round 107 (Rated for Div. 2)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 膀胱镜检查是什么
- 下一篇: 青麻的功效与作用是什么