Codeforces Round #660 (Div. 2)

好烦啊,又掉了点,挣扎了半天E,结果思路是错的。看到B就不想写, 图论是我爸爸

A.

只用前三个就可以了,如果有剩下的和前三个一样的就把14变成15。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=2e5+1000;
ll t,n,m;
int main(){
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>t;
    while(t--){
        cin>>n;
        if(n<31){
            cout<<"NO"<<endl;
        }else{
            ll a=6,b=14,c=10;
            if(n-a-b-c==6||n-a-b-c==10||n-a-b-c==14){
                b++;
            }
            cout<<"YES\n"<<a<<' '<<b<<' '<<c<<' '<<n-a-b-c<<endl;
        }
    }
    return 0;
}

B.

判断一下位数与4的关系就可以了

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=2e5+1000;
ll t,n,m;
int main(){
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>t;
    while(t--){
        cin>>n;
        ll eig=(n-1)/4+1;
        for(int i=0;i<n-eig;i++)cout<<9;
        for(int i=0;i<eig;i++) cout<<8;
        cout<<endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/Zabreture/p/13407491.html