Codeforces Round #371 (Div. 2)
来源:互联网 发布:网络用语qb是什么意思 编辑:程序博客网 时间:2024/05/20 23:30
A.
两线段的交为
再判断一下,交是否合法要省略的时间是否在交内就行
#include <iostream>#include <string.h>#include <queue>#include <cmath>#include <cstdio>#include <map>#include <string>#include <algorithm>using namespace std;int main(){ long long l1,l2,l,r1,r2,r,k; while(cin>>l1>>r1>>l2>>r2>>k){ l=max(l1,l2); r=min(r1,r2); long long ans=r-l+1; if(k>=l&&k<=r) ans--; cout<<max(ans,(long long)0)<<endl; }}
B.
要满足题意,只能出现三个点:最大点/最小点/当最大加最小是偶数时存在中间点
#include <iostream>#include <string.h>#include <queue>#include <cmath>#include <cstdio>#include <map>#include <string>#include <algorithm>using namespace std;const int MAXN=100000+5;long long a[MAXN];int main(){ int n; bool flag1; while(~scanf("%d",&n)){ map<long long,bool> flag; flag1=1; for(int i=0;i<n;i++) scanf("%lld",&a[i]); sort(a,a+n); flag[a[0]]=1;flag[a[n-1]]=1; if((a[0]+a[n-1])%2==0) flag[(a[0]+a[n-1])/(long long)2]=1; for(int i=0;i<n&&flag1;i++) if(flag[a[i]]==0) flag1=0; if(flag1) cout<<"YES"<<endl; else cout<<"NO"<<endl; }}C.
都按要求转化成18位就行
#include <iostream>#include <string.h>#include <queue>#include <cmath>#include <cstdio>#include <map>#include <string>#include <algorithm>using namespace std;string tr(long long x){ string str; for(int i=0;i<18;i++){ str+=x%2+'0'; x/=10; } //cout<<str<<endl; return str;}int main(){ int n; while(~scanf("%d",&n)){ getchar(); map<string,int> a; while(n--){ char b; long long c; scanf("%c %lld",&b,&c); getchar(); if(b=='+'){ a[tr(c)]++; }else if(b=='-'){ a[tr(c)]--; }else if(b=='?'){ cout<<a[tr(c)]<<endl; } } }}
二分搜?
E.
咋DP啊?
0 0
- Codeforces Round #371 (Div. 2)
- Codeforces Round #371 (Div. 2)
- Codeforces Round #371 (Div. 2)
- 【codeforces】Codeforces Round #371 (Div. 2)
- Codeforces Round #371 (Div. 2) E
- Codeforces Round #371 (Div. 2) E dp
- 【解题报告】Codeforces Round #371 (Div. 2)
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #104 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #107 (Div. 2)
- Codeforces Round #108 (Div. 2)
- Codeforces Round #110 (Div. 2)
- Codeforces Round #122 (Div. 2)
- Codeforces Round #121 (Div. 2)
- javaEE实现数据库信息简单显示在浏览器上
- 【技能储备】关于自学FreeMarker导出word的那些事
- ionic lab新建tab项目如何使用android的tab在底部
- POJ 2373 Dividing the Path DP -
- 实验二——任务一——打招呼
- Codeforces Round #371 (Div. 2)
- 由中秋抢月饼事件想到的
- 【35.43%】【hdu 4347】The Closest M Points
- 各种网络请求获取URL图片信息
- Struts2.0学习---Action名称的搜素顺序及配置的默认值
- 解决Visual Studio2015安装路径不能修改的问题
- hihoCoder #1240 : Image Encryption(最小表示法)
- 基于先序遍历和中序遍历序列构建二叉树结构【C语言】
- 数据结构学习笔记23 快速排序和基尔排序