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~~)的更多相关文章

  1. 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 ...

  2. Codeforces Round #100 E. New Year Garland (第二类斯特林数+dp)

    题目链接: http://codeforces.com/problemset/problem/140/E 题意: 圣诞树上挂彩球,要求从上到下挂\(n\)层彩球.已知有\(m\)种颜色的球,球的数量不 ...

  3. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. Codeforces Round #270 1002

    Codeforces Round #270 1002 B. Design Tutorial: Learn from Life time limit per test 1 second memory l ...

  6. 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 ...

  7. Codeforces Round #108 (Div. 2)

    Codeforces Round #108 (Div. 2) C. Pocket Book 题意 给定\(N(N \le 100)\)个字符串,每个字符串长为\(M(M \le 100)\). 每次选 ...

  8. Codeforces Round #110 (Div. 2)

    Codeforces Round #110 (Div. 2) C. Message 题意 给两个长度不超过2000的字符串\(s,u\),仅由小写字母构成. 找出\(s\)的一个子串\(t\),通过3 ...

  9. Codeforces Round #367 (Div. 2) C. Hard problem(DP)

    Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...

随机推荐

  1. Centos6.5安装

    前奏:CentOS 6.5下载地址http://mirror.centos.org/centos/6.5/isos/x86_64/CentOS-6.5-x86_64-bin-DVD1to2.torre ...

  2. ext 金额大写

    //数字转换成大写金额函数 function atoc(numberValue) { numberValue = numberValue.replace(/,/g,''); numberValue = ...

  3. [Linux]Vim的安装及使用

    1.安装:$sudo apt-get install vim 2.查看Vim所在路径$whereis vim 3.启动Vim $'/usr/bin/vim.tiny'  4. 退出Vim窗口:Ctrl ...

  4. angular 控制器之间值得传递

    <div ng-controller="ParentCtrl"> <!--父级--> <div ng-controller="SelfCtr ...

  5. gcc/g++编译

    1. gcc/g++在执行编译工作的时候,总共需要4步 (1).预处理,生成.i的文件[预处理器cpp] (2).汇编,将预处理后的文件转换成汇编语言,生成文件.s[编译器egcs] (3).编译,将 ...

  6. 用VS2010编写的C++程序,在其他电脑上无法运行,提示缺少mfc100.dll的解决办法

    问题: 在自己电脑上用VS2010编写的VC++程序(使用MFC库),不能在其他电脑上运行.双击提示: "无法启动此程序,因为计算机中丢失mfc100.dll 尝试重新安装该程序以解决此问题 ...

  7. Java反射的理解

    反射的作用:   1.运行时检查类的结构 2.运行时更改类的字段值 3.调用类的方法   准备知识:   Class类:虚拟机为每一个对象保存的一份对象所属类的清单: static Class for ...

  8. tyvj P1716 - 上帝造题的七分钟 二维树状数组区间查询及修改 二维线段树

    P1716 - 上帝造题的七分钟 From Riatre    Normal (OI)总时限:50s    内存限制:128MB    代码长度限制:64KB 背景 Background 裸体就意味着 ...

  9. GemFire

    一.GemFire是什么?   如果你了解Redis或memCached,那么恭喜,你很快就能理解GemFire是什么,没错,你可以把它理解为一个增强版的Redis,具体在哪些方面增强,我们日后慢慢聊 ...

  10. 总结Web应用中基于浏览器的安全漏洞

    ‍‍‍‍‍1.浏览器缓存 每次打开一个网站,网页的内容会缓存到用户的机器中.如果这些内容在其他网页中需要重新加载,浏览器加载的是缓存,而不是再次下载内容.如果一些Web应用商店以及显示用户敏感信息(比 ...