Codeforces Beta Round #67 (Div. 2)
Codeforces Beta Round #67 (Div. 2)
http://codeforces.com/contest/75
A
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int a,b,c;
cin>>a>>b;
c=a+b;
int ccc=;
int aa=,bb=,cc;
int p=;
while(a){
int tmp=a%;
if(tmp!=){
aa+=(tmp)*p;
p*=;
}
a/=;
}
p=;
while(b){
int tmp=b%;
if(tmp!=){
bb+=(tmp)*p;
p*=;
}
b/=;
}
p=;
while(c){
int tmp=c%;
if(tmp!=){
ccc+=(tmp)*p;
p*=;
}
c/=;
}
cc=aa+bb;
if(cc==ccc) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
B
模拟
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
string me;
cin>>me;
int n;
cin>>n;
map<string,int>M,S{{"posted",},{"commented",},{"likes",}};
for(string a,b,c,x;cin>>a>>b>>c>>x;M[a],M[c])
{
if(c=="on")c=x,cin>>x;
c.pop_back();c.pop_back();
if(a==me)M[c]+=S[b];
if(c==me)M[a]+=S[b];
}
vector<pair<int,string>>V;
for(map<string,int>::iterator it=M.begin();it!=M.end();it++)V.emplace_back(-it->second,it->first);
sort(V.begin(),V.end());
for(int i=;i<V.size();i++)if(V[i].second!=me)cout<<V[i].second<<endl;
}
C
二分+gcd
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int aa,bb,l,r,x,y;
int a[]; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>aa>>bb;
int n;
cin>>n;
int gcd=__gcd(aa,bb);
int co=;
int gg=sqrt(gcd);
a[co++]=;
for(int i=;i<=gg;i++){
if(gcd%i==){
a[co++]=i;
if(gcd/i!=gg){
a[co++]=gcd/i;
}
}
}
a[co++]=gcd;
sort(a+,a+co);
int mid;
for(int i=;i<=n;i++){
cin>>x>>y;
l=,r=co-;
while(l<=r){
mid=l+r>>;
if(a[mid]<=y) l=mid+;
else {
r=mid-;
}
}
if(a[r]>y) r--;
if(a[r]>=x&&a[r]<=y) cout<<a[r]<<endl;
else cout<<-<<endl;
}
}
D
应该是最大子段和的加强版吧,把最大前缀和,最大后缀和,最大子区间和求出来,然后找最大值
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; ll maxl[],maxr[],sum[],dp[],Right; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n,m;
cin>>n>>m;
int num;
int x;
for(int i=;i<=n;i++){
cin>>num;
maxl[i]=dp[i]=-0x3f3f3f3f;
Right=;
for(int j=;j<=num;j++){
cin>>x;
sum[i]+=x;
maxl[i]=max(sum[i],maxl[i]);
Right+=x;
dp[i]=max(dp[i],Right);
if(Right<) Right=;
}
maxr[i]=Right;
}
ll ans=-0x3f3f3f3f;
Right=;
for(int i=;i<=m;i++){
cin>>x;
ans=max(max(ans,dp[x]),Right+maxl[x]);
Right=max(Right+sum[x],maxr[x]);
}
cout<<ans<<endl;
}
E
几何,分类讨论即可
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; struct Point{
double x,y;
}a[],h[],s,e;
double ans;
int p[],n,m; double dis(Point a, Point b) {
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
} double cross(Point s, Point a, Point b) {
return (a.x - s.x) * (b.y - s.y) - (b.x - s.x) * (a.y - s.y);
} void check(Point a, Point b, Point c, Point d, int i) {
double t1 = cross(a, c, b), t2 = cross(a, b, d), t3 = cross(c, a, d), t4 = cross(c, d, b);
if (fabs(t1) < eps && fabs(t2) < eps) return ;
if (fabs(dis(a, c) + dis(c, b) - dis(a, b)) < eps) {
h[m] = c; p[m] = i; ++m; return ;
}
if (t1 * t2 > eps && t3 * t4 > eps) {
h[m].x = (t1 * d.x + t2 * c.x) / (t1 + t2);
h[m].y = (t1 * d.y + t2 * c.y) / (t1 + t2);
p[m] = i; ++m;
}
} double getl(int st, int en, int x, int y) {
double res; st = (st + ) % n; res = ;
for (int i = st; i != en; i = (i + ) % n)
res += dis(a[i], a[(i + ) % n]);
return res + dis(h[x], a[st]) + dis(a[en], h[y]);
} int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
// std::ios::sync_with_stdio(false);
cin>>s.x>>s.y>>e.x>>e.y>>n;
for (int i = ; i < n; ++i) cin>>a[i].x>>a[i].y;
for (int i = ; i < n; ++i) check(s, e, a[i], a[(i + ) % n], i);
if (m == ) {
if (dis(s, h[]) > dis(s, h[])) swap(h[], h[]), swap(p[], p[]);
ans = min(getl(p[], p[], , ), getl(p[], p[], , ));
ans = min(ans, dis(h[], h[]) * );
ans += dis(s, h[]) + dis(h[], e);
}
else ans = dis(s, e);
printf("%.7f\n",ans);
}
Codeforces Beta Round #67 (Div. 2)的更多相关文章
- 【计算几何】 Codeforces Beta Round #67 (Div. 2) E. Ship's Shortest Path
读懂题意其实是模板题.就是细节略多. #include<cstdio> #include<cmath> #include<algorithm> using name ...
- Codeforces Beta Round #67 (Div. 2)C. Modified GCD
C. Modified GCD time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
随机推荐
- Block 语法
Block,代码块,^符号是block的语法标记. 比如说,一个block的参数列表是一个UIView,返回值是个CGFloat,block名称是testBlock 可以定义为 CGFloat (^ ...
- Easy-to-Learn English Travel Phrases and Vocabulary!
Easy-to-Learn English Travel Phrases and Vocabulary! Share Tweet Share Tagged With: Real Life Englis ...
- MTIM(中间人攻击)
所谓的MITM攻击就是通过拦截正常的网络通信数据,并进行数据篡改和嗅探,而通信的双方却毫不知情. 信息篡改 当主机A.和主机B通信时,都由主机C来为其“转发”,如图一,而A.B之间并没有真正意思上的直 ...
- JAVA 16进制转ASCII -- 2018年5月25日 周五
/** * 16进制转ASCII * * @param hex * @return */ public static String hex2Str(String hex) { StringBuilde ...
- Android Studio3.1.2编译时Java Compiler出错:Warning: Failed to parse host proxy3.bj...
删除gradle.properties中的代理设置... #移除下面配置systemProp.http.proxyHost=proxy3.bj.petrochina systemProp.http.p ...
- ArcGIS案例学习笔记_3_2_CAD数据导入建库
ArcGIS案例学习笔记_3_2_CAD数据导入建库 计划时间:第3天下午 内容:CAD数据导入,建库和管理 目的:生成地块多边形,连接属性,管理 问题:CAD存在拓扑错误,标注位置偏移 教程:pdf ...
- 五, Authentication和Permissions
概述 在介绍Django REST Framework(二):Request和Response 时提到,DRF提供了对身份验证和权限的处理机制,特点如下: 1.对API的不同部分使用不同的认证策略: ...
- Anaconda安装及配合pycharm使用
首先到https://www.anaconda.com/download/下载合适的anaconda版本.如Windows 64bit. 下载了直接双击开始下载,一路同意下去,到选择安装的目录.这里选 ...
- 寒假生活第一天——Github初体验
快开学了,今天体验了一下github这个对我来说很是神秘的东西 它的定义来源于百度百科,如有异议,那就有吧.//gitHub是一个面向开源及私有软件项目的托管平台,因为只支持git 作为唯一的版本库格 ...
- session of express
[session of express] 1.express-session 一个提供session功能库 npm install express-session --save var session ...