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> ...
随机推荐
- PHPExcel在TP下使用
第一:你要去PHPExcel官网下载,然后放到网站的Vendor文件夹下面.当然这是为了好管理和导入.你放在其他位置也没有关系. 第二:当然是在你需要的地方写代码.我只写样例,你看懂了就可以灵活的使用 ...
- git的团队协作开发
title: git的团队协作开发 date: 2018-04-24 14:00:03 tags: [git] --- 项目负责人创建组织架构 在控制面板中点击组织按钮,添加组织,在这里可以把组织理解 ...
- 【Noip模拟 20161005】友好城市
问题描述 小ww生活在美丽的ZZ国.ZZ国是一个有nn个城市的大国,城市之间有mm条单向公路(连 接城市ii.jj的公路只能从ii连到jj).城市ii.jj是友好城市当且仅当从城市ii能到达城市jj并 ...
- jquery接触初级----jquery 对象和Dom对象
1. DOM 对象,每一份DOm对象(Document Object model)都可以表示成一棵树,一个基本的网页如下: <!DOCTYPE html> <html lang=&q ...
- golang使用Nsq(转)
为什么要使用Nsq 最近一直在寻找一个高性能,高可用的消息队列做内部服务之间的通讯.一开始想到用zeromq,但在查找资料的过程中,意外的发现了Nsq这个由golang开发的消息队列,毕竟是golan ...
- js相关文章
1.js获取网页屏幕可见区域高度 2.JS组件系列——BootstrapTable 行内编辑解决方案:x-editable 3.Bootstrap table 服务器端分页示例
- bug提单规范
一.提单模板 标题:[项目组][模块][子模块][发生原因]问题简要描述描述:[预置条件] 有就写清楚,没有就写无[操作步骤]1.XXXXX2.XXXXXX3.XXXXX[实际结果] XXXXX[预期 ...
- maven ,添加加密算法,使用
1:消息摘要:(数字指纹):既对一个任意长度的一个数据块进行计算,产生一个唯一指纹.MD5/SHA1发送给其他人你的信息和摘要,其他人用相同的加密方法得到摘要,最后进行比较摘要是否相同. MD5(Me ...
- asp.net控件中的reportview不显示
如果reportview在asp.net中,图标出不来,打X 1.安装reportview控件(在装有vs2010中的电脑中搜,不要去下载,下载可能会出错) 2.如果是iis7以上版本,web.con ...
- 吴裕雄 python深度学习与实践(6)
from pylab import * import pandas as pd import matplotlib.pyplot as plot import numpy as np filePath ...