Codeforces Round #438 868A/B/C
来源:互联网 发布:php函数大全 编辑:程序博客网 时间:2024/05/21 09:31
打了这么多次的cf,第一次上分啊,不容易,万事开头难!
第一题、标记一下两个字母,能凑出来,就行
#include<iostream>#include<cstdio>#include<cstring>using namespace std;char kk[5];char str[105][5];int vis[5];int main(){ int n; int flag; while(~scanf("%s",&kk)) { flag=0; memset(vis,0,sizeof(vis)); scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%s",str[i]); if(str[i][0]==kk[0] && str[i][1]==kk[1]) flag=1; if(str[i][0]==kk[1]) vis[1]=1; if(str[i][1]==kk[0]) vis[0]=1; } if(flag || (vis[0]==1 && vis[1]==1)) printf("YES\n"); else printf("NO\n"); } return 0;}
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;double a[3];double t1,t2,h,m,s;int judge(){ if(t1>a[0] && t1<a[1] && t2>a[0] && t2<a[1]) return 1; if(t1>a[1] && t1<a[2] && t2>a[1] && t2<a[2]) return 1; if( (t2<a[0] && t1<a[0]) || (t2>a[2] && t1>a[2]) || (t1<a[0] && t2>a[2]) || (t2<a[0] && t1>a[2] ) ) return 1; return 0;}int main(){ while(~scanf("%lf%lf%lf%lf%lf",&h,&m,&s,&t1,&t2)) { a[2]=(s/60*12); a[1]=(m/60*12)+a[2]/60; if(h>=12) h-=12; a[0]=h+a[1]/60; sort(a,a+3); if(judge()) printf("YES\n"); else printf("NO\n"); } return 0;}
第三题、寻找0,1能够互补的就行。充分利用二进制。
#include <iostream>#include <cstdio>#include <set>using namespace std;int res;set <int> ss;int n,k,flag;void Search(int x){ set <int>::iterator it; it=ss.find(x); if(it!=ss.end()) flag=1;}void dfs(int x,int t){ if(t==k) Search(x); else{ if(x&(1<<t)) dfs(x^(1<<t),t+1); else{ dfs(x^(1<<t),t+1); dfs(x,t+1); } }}int main(){ int x; while(~scanf("%d%d",&n,&k)) { flag=0; for(int i=0;i<n;i++) { res=0; for(int j=0;j<k;j++) { scanf("%d",&x); res+=(x<<j); } ss.insert(res); if(res==0) flag=1; } if(flag==1) { printf("YES\n"); continue; } set <int>::iterator it; for(it=ss.begin();it!=ss.end();it++) { dfs(*it,0); } if(flag==1) printf("YES\n"); else printf("NO\n"); } return 0;}
阅读全文
0 0
- Codeforces Round #438 868A/B/C
- Codeforces Round #438 A+B+C Contest 868
- Codeforces Beta Round #1 A B C
- Codeforces Beta Round #1 A B C
- Codeforces Beta Round #2 A B C
- Codeforces Round #231 A,B,C
- Codeforces Round #278(Div2) A B C
- Codeforces Round #300 A B C
- Educational Codeforces Round 8 (A B C)
- Codeforces Round #351 A B C D
- Codeforces Round #377 A.B.C.D
- Codeforces Round #399 (A,B,C)
- Codeforces Beta Round #1 A,B,C
- Codeforces Beta Round #1 A,B,C
- Codeforces Beta Round #1 A,B,C
- Codeforces Beta Round #1 A,B,C
- Codeforces Beta Round #1 A,B,C
- Codeforces Beta Round #1 A,B,C
- 最大连续子序列和
- 初始 RPC 框架
- codeforces 367B
- 神经网络 ——一个很好的解释以及简单实现 Implementing a Neural Network from Scratch in Python – An Introduction
- 第3章 栈和队列综合习题(leetcode+vjudge)
- Codeforces Round #438 868A/B/C
- 原声js鼠标滚一次一屏
- 安装zabbix前端时的 check of pre-requisites 问题
- C++ 接口(抽象类)
- LinkedList-二叉树遍历
- Big Christmas Tree POJ
- HDU 1715 大菲波数
- 傅里叶变换最轻松的理解
- javaBean验证框架(5)—自定义类级别约束