Codeforces Global Round 8

A. C+=

题目链接

水题,就每一次用小的加大的,保留大的就行了
具体看代码叭

#include<bits/stdc++.h>
using namespace std;
int t,a,b,n;

int main()
{
    ios::sync_with_stdio(false);
    cin>>t;
    while(t--){
        cin>>a>>b>>n;
        if(b>a) swap(a,b);
        int ans=0;
        while(a<=n){
            b+=a;
            ans++;
            swap(a,b);
        }
        cout<<ans<<"\n";
    }
    return 0;
}

B. Codeforces Subsequences

题目链接

啊这题最开始想的是对n分解质因数(我只当了观众),后来发现是每个数的个数从1开始增加就行了

#include<bits/stdc++.h>
using namespace std;
char s[]="codeforces";
long long  n,rec[20];


int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    memset(rec,0,sizeof(rec));
    for(int i=0;i<strlen(s);i++) rec[i]=1;
    long long ans=1;
    while(ans<n){
        for(int i=0;i<strlen(s);i++){
            ans/=rec[i];
            rec[i]++;
            ans*=rec[i];
            if(ans>=n) break;
        }
    }
    for(int i=0;i<strlen(s);i++){
        for(int j=0;j<rec[i];j++){
            cout<<s[i];
        }
    }
    cout<<"\n";
    return 0;
}

C. Even Picture

题目链接

啊这个,开场先看的就是c题,没怎么看懂,所以没打了。
具体怎么构造的直接看代码叭

#include<bits/stdc++.h>
using namespace std;
int n;
//vector<pair<int,int > >rec;


int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    int rec=0;
    cout<<n*3+4<<"\n";
    for(int i=0;i<n+2;++i){
        if(i==0||i==n+1){
            for(int j=0;j<2;++j) cout<<j+rec<<" "<<i<<"\n";
        }else{
            for(int j=0;j<3;++j) cout<<j+rec<<" "<<i<<"\n";
            ++rec;
        }
    }
    return 0;
}

余下代补

posted @ 2020-06-20 00:03  0xDkXy_DWM  阅读(68)  评论(0编辑  收藏  举报