zoukankan      html  css  js  c++  java
  • codeforces Hello 2019(未写完)

    A. Gennady and a Card Game

    a题惯例签到题

    题意:给你一张牌,再给你5张牌,判断能不能出一次牌...

    所以只要检查第二行中的某个卡是否与第一行中的卡具有共同字符

    有就输出YES否则输出NO

    #include<iostream>
    #include<cstring>
    #include<cstdio>
    using namespace std;
    char a,b,s[101];
    bool tf=0;
    int main(){
    	scanf("%c%c",&a,&b);
    	for(int i=0;i<5;i++){
    		scanf("%s",s);
    		if(s[0]==a||s[1]==b) tf=1;
    	}
    	if(tf) cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
    	return 0;
    }
    

      

    B. Petr and a Combination Lock

    题意:检查角度是否为360度的倍数。

    这题让我第一次见识到了被hack...

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int a[101],n,x;
    bool tf=0;
    int main(){
    	scanf("%d",&n);
    	for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
    	for(int i=0;i<1<<n;++i){
    		x=0;
    		for(int j=1;j<=n;++j)
    			if((1<<(j-1))&i) x+=a[j];
                    else x-=a[j];
    		if((x==0)||(x%360==0)) tf=1;
    	}
    	if (tf) cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
    	return 0;
    }
    

      

  • 相关阅读:
    Luogu P1596 [USACO10OCT]湖计数Lake Counting
    Luogu P1757 通天之分组背包
    数据建模笔记1
    单纯形算法 matlab
    有效集 matlab代码
    拟牛顿 DFP matlab
    FR共轭梯度法 matlab
    整数规划
    线性规划 Matlab
    远期、期货和互换(三)
  • 原文地址:https://www.cnblogs.com/wjnclln/p/10223428.html
Copyright © 2011-2022 走看看