2018_清明第二场

a
* A题
* A - Bulbs CodeForces - 615A
* 模拟出开关的情况即可
* ac如下

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <set>
#define mm(a,b) memset(a,b,sizeof(a))
#define up(a,b) for(int a = 1;a <= b;a++)
using namespace std;

int n;
int m;
int x;
int y[105];
int t;
bool ok;
int main(){
    while(~scanf("%d %d",&n,&m)){
        mm(y, 0);
        ok = false;
        memset(y,1,(m+1)*sizeof(int));
        up(i, n){
            scanf("%d",&x);
            up(j, x){
                scanf("%d",&t);
                y[t] = 0;
            }
        }
        int ans = 0;
        up(i, m){
            if(y[i] == 0)   ans++;
        }
        if(ans == m){
            cout<<"YES"<<endl;
        }
        else    cout<<"NO"<<endl;
    }
    return 0;
}

B
B - Bachgold Problem CodeForces - 749A
* 找最小的质数
* 就是一堆2 然后判断最后一位为2 或者 3

#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    int k;
    while(~scanf("%d",&k)){
        cout<<k/2<<endl;
        for(int i = 1;i < k/2;i++){
            cout<<"2 ";
        }
        if(k%2==1){
            cout<<"3"<<endl;
        }
        else{
            cout<<"2"<<endl;
        }
    }
    return 0;
}

D
D - Parallelogram is Back CodeForces - 749B
* 题意:由平行四边形法则求另外一个(多个)点的坐标
* 要求能构成平行四边形
* 从三边分别延展成3种

#include<iostream>
#include<cstdio>
using namespace std;

struct node{
    int x,y;
}nd[4];

int main()
{
    for(int i = 1;i <= 3;i++){
        scanf("%d%d",&nd[i].x,&nd[i].y);
    }
    int tx = nd[1].x-nd[2].x;
    int ty = nd[1].y-nd[2].y;
    int dx = nd[3].x-nd[1].x;
    int dy = nd[3].y-nd[1].y;
    cout<<"3"<<endl;
    printf("%d %d\n",nd[2].x-dx , nd[2].y-dy);
    printf("%d %d\n",nd[3].x+tx , nd[3].y+ty);
    printf("%d %d\n",nd[3].x-tx , nd[3].y-ty);
    return 0;
}

F
F - Voting CodeForces - 749C
* 模拟
* 模拟投票

#include <cstdio>
#include <queue>
#include <cstring>
#include <cstdlib>
using namespace std;
char vote[200001];
queue <int> D;
queue <int> R;
int main(){
    int N;
    cin>>N>>vote;
        for(int i = 0 ; i < N; i++){
            if(vote[i] == 'D') D.push(i);
            else R.push(i);
        }
        while(R.size() && D.size()){
            int r = R.front();
            int d = D.front();
            R.pop();
            D.pop();
            if(r < d){
                R.push(N+r);
            }
            else{
                D.push(N+d);
            }
        }
        if(R.size())    cout<<"R"<<endl;
        else            cout<<"D"<<endl;
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值