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. windows下安装wamp和wordpress

    安装wamp WAMP是一个windows上的php开发集成环境,一键安装php,apache和mysql,非常方便. 双击wampserver2.2exxxxxxxxxx.exe文件进行安装,安装过 ...

  2. CSS3—CSS3和现代Web设计

    1.1 现代Web设计理念 1.1.1 可访问性第一 同样一段内容, 可以用成千上万的方法为其设计样式, 但全世界的用户应该依然可以访问它们, 不管他们用什么方式去访问Web——无论手机.键盘控制器还 ...

  3. EF+WCF怎样更新数据?

    public virtual void Update(T entity) { T current = this.Where(m => m.Id.Equals(entity.Id)) .Singl ...

  4. 搬瓦工vps搭建vpn

    一.下载centos6一键安装包 wget --no-check-certificate https://raw.githubusercontent.com/teddysun/across/maste ...

  5. 链表与Hash检索实测

    测试环境: Win7 SP1.8G内存.3.4GHz 4核 测试代码: using System; using System.Collections.Generic; using System.Lin ...

  6. 趣味C程序100.1 .2 绘制正弦曲线

    说明:1.本问题来源于<C语言经典.趣味.实用程序设计编程百例精解>,所有程序为本人自己编写.与原程序不同之处作有标记. 2.本系列所有程序均使用codeblocks编译,操作系统为Win ...

  7. Contest 20141027 总结

    这次考试主要问题出在第一题,由于考试期间没有看清题意,少看了一句 “a=A/1e9" 导致在考试结束最后5分钟发现时修改过于匆忙,改出问题了.另外,这道题同时告诉我long double 在 ...

  8. Arrays.fill方法的陷阱

            昨晚调试程序时发现的,该方法不能初始化二维数组,不过当时没有报CE,提交的时候也是WA:今早上单独测试该方法,也没有CE,不过运行时异常.切记

  9. BlockingQueue队列学习

    今天看了下BlockingQueue的几种实现,记录下以便以后复习. 首先来看一下BlockingQueue的家族成员: BlockingQueue除了先进先出外,还有两个操作:在队列为空时,获取元素 ...

  10. Android SectionIndexer 的使用(联系人分类索引)

    // 获取标题栏索引 int position = sectionIndexter.getPositionForSection(l[idx]); ) { return true; } // 设置调整到 ...