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. [Twisted] deferred

    Twisted提供一个优雅的实现(Deferred)来管理回调函数. Deferred Object 的结构 Deferred Object包含两个回调函数列表.一个用来保存成功的回调函数,另一个用来 ...

  2. iOS RegexKitLite的使用以及常用的正则表达式

    1.去RegexKitLite下载类库,解压出来会有一个例子包及2个文件,其实用到的就这2个文件,添加到工程中. 2.工程中添加libicucore.dylib frameworks. 3.现在所有的 ...

  3. 生产者与消费者(一)---wait与notify

    生产者消费者问题是研究多线程程序时绕不开的经典问题之一,它描述是有一块缓冲区作为仓库,生产者可以将产品放入仓库,消费者则可以从仓库中取走产品.解决生产者/消费者问题的方法可分为两类: (1)采用某种机 ...

  4. ACM HDU 1021 Fibonacci Again

    #include<iostream> using namespace std; int main() { int n; while(cin>>n) { if((n+1)%4== ...

  5. phpmailer{群发并且发送附件}

    PHPMailer是一个用于发送电子邮件的PHP函数包. 第一,需要下载PHPMailer文件包phpmailer. http://phpmailer.sourceforge.net/     第二, ...

  6. jQuery慢慢啃之工具(十)

    1.jQuery.support//一组用于展示不同浏览器各自特性和bug的属性集合 2.jQuery.browser//浏览器内核标识.依据 navigator.userAgent 判断. 可用值: ...

  7. css3 iphone开关 移动端开关、按钮、input

    css3  iphone开关  移动端开关.按钮.input <!DOCTYPE html> <html> <head> <meta charset=&quo ...

  8. win8 + ubuntu14.04 安装步骤

    一.首先,从硬盘上划分一个空闲分区(推荐最少20G,每个人也可以按照自己的需要自行设定).记住各个分区的容量,方便安装时辨认.并从Ubuntu官方网站上下载Ubuntu 14.04 LTS 光盘镜像. ...

  9. vscode编写插件详细过程

    前言 之前编写了一个vscode插件用vscode写博客和发布,然后有园友要求写一篇来介绍如何开发一个vscode扩展插件,或者说介绍开发这个插件的过程.然而文章还没有写,园子里面已经有人发布一个文章 ...

  10. 从一个模板函数聊聊模板函数里面如何获得T的名字

    写了个小程序,遇到点问题.总结总结,学习学习 #include<vector> #include<iostream> #include<typeinfo> usin ...