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 ...
随机推荐
- c# ADO连接Access 执行Open后程序自动退出
今天利用ADO连接Access数据库的时候遇到了前所未见的问题,Access数据库连接串,OleDbConnection,open的时候,系统就会自动关闭所有调试. 我就很纠结了,这个AccessHe ...
- OC基础-day02
#pragma mark - Day02_01_对象的创建与使用 1)如何通过类创建一个对象 1. 类是抽象的,无法直接使用 2. 对象是类的一个具体实现,可以直接使用 3. 语法 类名 *对象名 = ...
- 速卖通api--获取商品信息
<? $productId = 'xxxx';//你的产品id $access_token = 'xxxxx';//你的授权码 $appSecret = 'xxxx';/ ...
- chromium安装flash
sudo apt-get install pepperflashplugin-nonfree sudo update-pepperflashplugin-nonfree --install Flash ...
- centos 6.5 openfire安装
1.下载:http://igniterealtime.org/downloads/download-landing.jsp?file=openfire/openfire-3.9.3-1.i386.rp ...
- 子网/ip/子网掩码
IP地址由网络地址和主机地址组成 而现在IP由“子网掩码”通过子网网络地 址细分出 A,B,C类更小的网络.这种方式 实际上就是将原来的A类,B类,C类等分类 中的的主机地址部分用作子网地址,可以 将 ...
- jquery 左侧展开栏目
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- centos下的lnmp环境搭建
1.配置centos的第三方yum源,因为原始的yum是无法安装nginx的 wget http://www.atomicorp.com/installers/atomic 下载atomic yum ...
- 链表与Hash检索实测
测试环境: Win7 SP1.8G内存.3.4GHz 4核 测试代码: using System; using System.Collections.Generic; using System.Lin ...
- 推荐用于格式化以及高亮显示SQL文的PHP类-SqlFormatter
有时候做开发用到SQL文的时候,由于sql文太长,很难真正看清楚这个sql文的结构. 所以需要一个工具能够自动对SQL文进行排版,在网上有幸找到这个用php写的类能处理这个任务. 原文地址是http: ...