Codeforces Beta Round #69 (Div. 2 Only)
Codeforces Beta Round #69 (Div. 2 Only)
http://codeforces.com/contest/80
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 n,m;
cin>>n>>m;
for(int i=n+;;i++){
int flag=;
int j;
for(j=;j<i;j++){
if(i%j==){
break;
}
}
if(j==i) {
if(i==m) cout<<"YES"<<endl;
else {
cout<<"NO"<<endl;
}
break;
}
}
}
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);
double n,m;
char ch;
cin>>n>>ch>>m;
if(n>=) n-=;
double ans1,ans2;
ans2=*m;
ans1=n*+0.5*m;
cout<<ans1<<" "<<ans2<<endl;
}
C
因为有三个敌人,所以用三进制的方法枚举所有的情况。时间复杂度为O(3^7*7*7)
#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; map<string,ll>mp;
string s[]={"Anka","Chapay","Cleo","Troll","Dracul","Snowy","Hexadecimal"};
ll relation[][]; int book[]; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n;
string s1,s2,s3;
for(int i=;i<;i++){
mp[s[i]]=i+;
}
cin>>n;
for(int i=;i<=n;i++){
cin>>s1>>s2>>s3;
relation[mp[s1]][mp[s3]]++;
}
ll a,b,c;
cin>>a>>b>>c;
int m=******;
set<int>se;
ll ans1=0x3f3f3f3f;
int ans2=;
for(int i=;i<=m;i++){
int j=i;
se.clear();
int co=;
memset(book,,sizeof(book));
while(j){
book[co]=j%;
se.insert(book[co]);
co++;
j/=;
}
if(se.size()==){
int aa=,bb=,cc=;
for(j=;j<=;j++){
if(book[j]==) aa++;
else if(book[j]==) bb++;
else if(book[j]==) cc++;
}
ll aaa=a/aa;
ll bbb=b/bb;
ll ccc=c/cc;
if(aaa>bbb) swap(aaa,bbb);
if(aaa>ccc) swap(aaa,ccc);
if(bbb>ccc) swap(bbb,ccc);
if(ccc-aaa<ans1){
ans1=ccc-aaa;
ans2=;
for(int q=;q<=;q++){
for(int w=;w<=;w++){
if(relation[q][w]&&book[q]==book[w]){
ans2++;
}
}
}
}
else if(ccc-aaa==ans1){
int tmp=;
for(int q=;q<=;q++){
for(int w=;w<=;w++){
if(relation[q][w]&&book[q]==book[w]){
tmp++;
}
}
}
ans2=max(ans2,tmp);
}
}
}
cout<<ans1<<" "<<ans2<<endl;
}
D
要让delta>=0的情况为p-4q>=0。因此可以画出几何图形
以样例一为例子:红色部分就是需要求的概率

#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 t;
scanf("%d",&t);
while(t--){
int a,b;
scanf("%d %d",&a,&b);
if(a==&&b==) printf("%.7f\n",*1.0);
else if(a==&&b!=){
printf("%.7f\n",0.5);
}
else if(a!=&&b==){
printf("%.7f\n",*1.0);
}
else if(a>=*b){
printf("%.7f\n",(a-b)*1.0/a);
}
else{
printf("%.7f\n",(a/4.0+*b)*1.0/(*b));
}
}
}
E
先做dfs,dfs的过程中对儿子可获得的最大果子进行排序,优先获取最大的果子,如果遍历完儿子之后自身的果子还有剩,就再对儿子进行一次遍历,这次遍历的目的是消耗儿子自身和自己的果实数量
#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; vector<int>ve[];
int a[];
int n; void dfs(int now,int pre,ll &Max,int &remain){
vector<ll>ve_Max;
vector<int>ve_remain;
for(int i=;i<ve[now].size();i++){
if(ve[now][i]!=pre&&a[ve[now][i]]>){
ll tmp_Max;
int tmp_remain=a[ve[now][i]]-;
dfs(ve[now][i],now,tmp_Max,tmp_remain);
ve_Max.pb(tmp_Max);
ve_remain.pb(tmp_remain);
}
}
sort(ve_Max.begin(),ve_Max.end());
Max=;
for(int i=ve_Max.size()-;i>=&&remain;i--){
Max+=ve_Max[i]+;
remain--;
}
for(int i=;i<ve_remain.size()&&remain;i++){
Max+=min(remain,ve_remain[i])*;
remain-=min(remain,ve_remain[i]);
}
} int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n;
for(int i=;i<=n;i++) cin>>a[i];
int u,v;
for(int i=;i<n;i++){
cin>>u>>v;
ve[u].pb(v);
ve[v].pb(u);
}
int fa;
cin>>fa;
ll ans=;
dfs(fa,,ans,a[fa]);
cout<<ans<<endl;
}
Codeforces Beta Round #69 (Div. 2 Only)的更多相关文章
- Codeforces Beta Round #69 (Div. 1 Only) C. Beavermuncher-0xFF 树上贪心
题目链接: http://codeforces.com/problemset/problem/77/C C. Beavermuncher-0xFF time limit per test:3 seco ...
- Codeforces Beta Round #63 (Div. 2)
Codeforces Beta Round #63 (Div. 2) http://codeforces.com/contest/69 A #include<bits/stdc++.h> ...
- 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> ...
随机推荐
- OWASP安全编码规范快速参考指南
0x00 原则 概览 开发安全的软件需要对安全原则有基本的了解.虽然对于安全原则的全面评估超出了本指南的范围,但是我们还是提供了一个快速的概览.软件安全的目标是要维护信息资源的 保密性 , 完整性 ...
- php计算程序运行时间
这里介绍一下 microtime() 这个函数,microtime() 用的不多,但是不能不知道这个函数,它是返回当前 Unix 时间戳和微秒数.例如:echo microtime(); 会返回:0. ...
- 机器学习进阶-图像基本操作-数值计算 1.cv2.add(将图片进行加和) 2.cv2.resize(图片的维度变换) 3.cv2.addWeighted(将图片按照公式进行重叠操作)
1.cv2.add(dog_img, cat_img) # 进行图片的加和 参数说明: cv2.add将两个图片进行加和,大于255的使用255计数 2.cv2.resize(img, (500, ...
- psutil模块
python模块之psutil 一.psutil模块 1.介绍 psutil是一个跨平台库(http://pythonhosted.org/psutil/)能够轻松实现获取系统运行的进程和系统利用率( ...
- Django - session 会话跟踪技术
1.session简介 |session 英 /'seʃ(ə)n/ 美 /'sɛʃən/ 基于cookies开发,将值存到服务端 写session 读session Session是服务器端技术,利用 ...
- iOS 申请distribution证书, 公钥,私钥
私钥只有在本机生成CSR文件的时候会产生,公钥会在CSR文件传给apple时,apple产生.
- java通过过滤器 设置跨域允许
前人种树:https://www.cnblogs.com/CBDoctor/p/4235082.htmlhttps://blog.csdn.net/yuting0787/article/details ...
- MySQL5.7 并行复制配置
转自:https://www.cnblogs.com/langdashu/p/6125621.html [MySQL] 号称永久解决了复制延迟问题的并行复制,MySQL5.7 一.缘由: 某天看到主从 ...
- img标签在div里上下居中
方法一:图片尺寸未知,IE8-不支持 CSS部分: <style> .content{ width:500px; height:500px; border:1px solid black; ...
- Linux crontab使用方法
crontab命令主要用于设置命令行或者脚本周期性的执行.该命令从标准输入设备读取指令,并将其存放于文件中,以供之后读取和执行.本文主要讲述crontb命令的基本语法和配置方法. 1.crontab命 ...