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> ...
随机推荐
- MySQL把一个大表拆分多个表后,如何解决跨表查询效率问题
大表分表后每个表的结构相同,可以用sql的union 比如a,b表结构相同可以通过union来联接 select * from aunion allselect * from bwhere.... 其 ...
- Spring Cloud Config中文文档
https://springcloud.cc/spring-cloud-config.html 目录 快速开始 客户端使用 Spring Cloud Config服务器 环境库 健康指标 安全 加密和 ...
- 机器学习进阶-图像基本操作-边界补全操作 1.cv2.copyMakeBoder(img, top_size, bottom_size, left_size, right_size, cv2.BORDER_REPLICATE) 进行边界的补零操作 2.cv2.BORDER_REPLICATE(边界补零复制操作)...
1.cv2.copyMakeBoder(img, top_size, bottom_size, left_size, right_size, cv2.BORDER_REPLICATE) 参数说明: i ...
- canal 入门
参考文章:Canal - 安装 https://www.aliyun.com/jiaocheng/1131288.html?spm=5176.100033.2.7.7b422237XAirIe 前 ...
- opencv给图片添加文字水印<转>
其中有一些改动为了文字大小等还有一些图片的尺寸,真正使用的时候可以把尺寸的屏蔽掉 头文件: //==================================================== ...
- Word Ladder 有必要深究。非图的广度优先遍历。标记
感觉很生疏. https://leetcode.com/problems/word-ladder/
- Delphi 泛型详解
http://www.cnblogs.com/jxgxy/category/216671.html
- html中,纯数字或纯英文的一串字符超出父容器不会折行显示,如何解决?
这种情况在软件使用过程中一般不会出现,只有测试人员在测试的时候手比较贱会给你弄一个这种数据,当然这也算是bug吧. 如图:“经营范围”的值严重超出父容器长度,并且没有像“服务信息”一样折行显示.这种情 ...
- debug.keystare找不到的解决办法[转]
重装系统之后,丢失了debug.keystore,找了很久都没有找到,根据网上所讲的只要重新运行一个android项目;就会在avd中生成一个新的debug.keystroe,此法也没解决,索性直接重 ...
- java-学习4
一.八大数据类型—dataType 整型 1)byte 2)short 3)int 4)long 浮点型 5)float 6)double 字符型 7)char 布尔型 8)boolean 二.变量和 ...