Codeforces Round #100(140~~)
140 A. New Year Table
题目大意:有一个大圆桌子,半径是R, 然后有n个半径是r的盘子,现在需要把这些盘子摆放在桌子上,并且只能摆放在桌子边缘,但是不能超出桌子的范围....问能放摆放下。
分析:先求出如果可以摆放n个盘子的最大夹角a,然后计算出来两个圆之间的距离,就可以判断出来是否能摆放下,注意1的时候需要特殊判断。
#include<stdio.h>
#include<math.h> const double PI = acos(-1.0);
const double EPS = 1e-; int Sign(double x)
{
if(x > EPS)return ;
if(fabs(x) < EPS)return ;
return -;
} int main()
{
int n, R, r; scanf("%d%d%d", &n, &R, &r); double a = PI / (n*1.0);
double L = R-r; int k = Sign((sin(a)*L)-r*1.0); if((n == && r <= R) || (n != && k>=) )
printf("YES\n");
else
printf("NO\n"); return ;
}
140 B. New Year Cards
题目大意:这个叫亚历山大的男子有n个朋友,他的这n个朋友编号从 1到n,然后时间 i(1<=i<=n)的时候他的朋友 i 给他发送贺卡 i....当然收到贺卡就需要回复,他本来没有贺卡,不过他回复遵循两个原则,1.他不会把一个朋友发给他的贺卡再给他这个朋友发过去。 2.他会从已有的贺卡里面选出一张他最喜欢的发送给他的朋友。他可以选择任意时间给每个朋友发送贺卡,当然他也希望最大满足朋友的喜好,所以会尽量发别人喜欢的贺卡,求出来给每个人发送贺卡的时间点。
分析:因为要求的是什么时候发送,而且要最大满足喜好,所以可以从每个人喜欢的贺卡开始判断,这个贺卡能不能被发出,被发出判断的条件很明显是前面没有比它小的值,或者有一个比它小的值并且这个值就是这个人(这样就会满足第一个条件),预处理一下就行了。
#include<stdio.h>
#include<math.h> const int MAXN = ; int like[MAXN][MAXN]; int main()
{
int N, index[MAXN]; scanf("%d", &N); for(int i=; i<=N; i++)
for(int j=; j<=N; j++)
scanf("%d", &like[i][j]); for(int i=; i<=N; i++)
{
scanf("%d", &like[][i]);
index[like[][i]] = i;
} int Time[MAXN], send[MAXN]={};
///send[]-1表示这个不可能发送,有数字表示这个只能发送给他
///send[]等于0表示这个人可以接收这个卡
for(int i=; i<=N; i++)
for(int j=; j<i; j++)
{
if(like[][i] > like[][j])
{
if(send[i] == )
send[i] = like[][j];
else
{
send[i] = -;
break;
}
}
} for(int i=; i<=N; i++)
for(int j=; j<=N; j++)
{
if(like[i][j] == i)
continue; int k = index[like[i][j]]; if(!send[k] || send[k] == i)
{
Time[i] = like[i][j];
break;
}
} for(int i=; i<=N; i++)
printf("%d%c", Time[i], i==N?'\n':' '); return ;
}
140 C. New Year Snowmen
题目大意:有n个不同半径的雪球,堆雪人需要三个不同半径的雪球,求出来最多能堆几个雪人。。。并且输出每个雪人的雪球大小(降序)
分析:因为给的半径比较大,所以先进行一下离散化,求出来每种半径的雪球有多少个,然后维护一个优先队列,每次都取最多的三个雪球,直到队列里面的数小于3.
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string.h>
using namespace std; const int MAXN = 1e5+; int Hash[MAXN], r[MAXN];
int sum[MAXN]; struct Radii
{
int id, cnt;
bool operator < (const Radii &t)const{
return cnt < t.cnt;
}
}; int ans[MAXN][]; int main()
{
int N, M, k=; scanf("%d", &N); for(int i=; i<N; i++)
{
scanf("%d", &r[i]);
Hash[i] = r[i];
} sort(Hash, Hash+N);
M = unique(Hash, Hash+N) - Hash; memset(sum, , sizeof(sum)); for(int i=; i<N; i++)
{
int id = lower_bound(Hash, Hash+M, r[i]) - Hash;
sum[id]++;
} priority_queue<Radii> Q;
Radii p; for(int i=; i<M; i++)
{
if(sum[i])
{
p.id = i;
p.cnt = sum[i];
Q.push(p);
}
} Radii Out[]; while(Q.size() > )
{
for(int i=; i<; i++)
{
Out[i] = Q.top();
Q.pop();
ans[k][i] = Hash[Out[i].id];
Out[i].cnt -= ;
}
for(int i=; i<; i++)
{
if(Out[i].cnt)
Q.push(Out[i]);
}
k++;
} printf("%d\n", k); for(int i=; i<k; i++)
{
sort(ans[i], ans[i]+);
printf("%d %d %d\n", ans[i][], ans[i][], ans[i][]);
} return ;
}
140 D. New Year Contest
题目大意:有一个比赛,比赛时间从18:00 - 6:00 比赛前10分钟思考策略,不进行答题,他计算出解决每个问题需要的时间,不过这个罚时比较特殊,罚时为提交的时间到达24:00的时间,不过做题可以解决好先不提交,提交不占时间,求出来去多解决多少问题,并且最少的罚时是多少。
分析:比较容易的贪心,先从小到达进行排序,然后取就行了。。。顺便记录罚时。。。
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string.h>
using namespace std; const int MAXN = ; int main()
{
int N, time[MAXN]; scanf("%d", &N); for(int i=; i<N; i++)
scanf("%d", &time[i]);
sort(time, time+N); int i, sum=, pen=; for(i=; i<N; i++)
{
if(sum + time[i] <= )
sum += time[i];
else if(sum+time[i] > && sum+time[i] <= )
{
sum += time[i];
pen += sum - ;
}
else if(sum + time[i] > )
break;
} printf("%d %d\n", i, pen); return ;
}
Codeforces Round #100(140~~)的更多相关文章
- Codeforces Round #100 A. New Year Table
A. New Year Table time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Codeforces Round #100 E. New Year Garland (第二类斯特林数+dp)
题目链接: http://codeforces.com/problemset/problem/140/E 题意: 圣诞树上挂彩球,要求从上到下挂\(n\)层彩球.已知有\(m\)种颜色的球,球的数量不 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #270 1002
Codeforces Round #270 1002 B. Design Tutorial: Learn from Life time limit per test 1 second memory l ...
- Codeforces Round #346 (Div. 2)---E. New Reform--- 并查集(或连通图)
Codeforces Round #346 (Div. 2)---E. New Reform E. New Reform time limit per test 1 second memory lim ...
- Codeforces Round #108 (Div. 2)
Codeforces Round #108 (Div. 2) C. Pocket Book 题意 给定\(N(N \le 100)\)个字符串,每个字符串长为\(M(M \le 100)\). 每次选 ...
- Codeforces Round #110 (Div. 2)
Codeforces Round #110 (Div. 2) C. Message 题意 给两个长度不超过2000的字符串\(s,u\),仅由小写字母构成. 找出\(s\)的一个子串\(t\),通过3 ...
- Codeforces Round #367 (Div. 2) C. Hard problem(DP)
Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...
随机推荐
- CSS Text文本格式
Text Color 颜色属性被用来设置文字的颜色. 颜色是通过CSS最经常的指定: 十六进制值 - 如"#FF0000" 一个RGB值 - "RGB(255,0,0)& ...
- [转] 博闻强识:了解CSS中的@ AT规则 ---张鑫旭
by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=4900 大家可能在CS ...
- 禁用微信 webview 调整字体大小
原文:http://www.grycheng.com/?p=2411 微信 webview 内置了调整字体大小的功能,对于网页的可用性来说是一个很实用的功能.一些网页的字体设置过小导致用户看不清文字, ...
- ExecuteReader
最近在做winform的编程,想到一真没有使用过ExecuteReader.可能以前以后它的用户不大,或者 不大好用,故没有用过.今天在这里将学习记录写下来,供读者参考: 1.MSDN上说:Sends ...
- Attributes(2): Displaying attributes for a class.(显示类属性)
输出类属性 using System; using System.Reflection; namespace Attribute02 { //用于Class和Struct类型 [Attribu ...
- Hadoop, Python, and NoSQL lead the pack for big data jobs
Hadoop, Python, and NoSQL lead the pack for big data jobs Rise in cloud-based analytics could incr ...
- 2016022602 - redis安装和启动
redis安装 我使用的是ubuntu15.1,打开终端,输入命令:sudo apt-get install redis-server 将会在本机安装上redis. 启动redis 启动redis命令 ...
- IntelIoT技术笔记Maven
1.Maven project facet配置 错误信息: One or more constraints have not been satisfied.以及Cannot change versio ...
- jquery 滑动动画
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <head> ...
- [译]36 Days of Web Testing(三)
Day 14: Automate the tedious Why ? 有些时候,web测试还是蛮单调乏味的,在开始测试前,你可能要必须跳转到一个特定的表单页面,或则为了得到一个特定的页面(或配置),你 ...