【GYM101409】2010-2011 ACM-ICPC, NEERC, Western Subregional Contest
A-Area and Circumference
题目大意:在平面上给出$N$个三角形,问周长和面积比的最大值。
#include <iostream>
#include <algorithm>
#include <cstring>
#include <stdio.h>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <iomanip>
using namespace std;
const int N=1e5+;
//const double eps = 1e-8;
double ax,ay,bx,by;
double x[N];
double chang,kuan;
int main()
{
freopen("area.in","r",stdin);
freopen("area.out","w",stdout);
int n;
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%lf%lf%lf%lf",&ax,&ay,&bx,&by);
chang=fabs(bx-ax);
kuan=fabs(ay-by);
x[i]=chang*kuan/(chang+chang+kuan+kuan);
}
sort(x+,x++n);
printf("%lf\n",x[n]);
}
B-Brothers
题目大意:找出区间$[M,N]$上的质数数对$(X,Y)$的个数,满足$Y=X+2010$。
题解:预处理出$ans[i]$表示$[1,i \times 10^6]$的答案,对于区间$[1,N]$的答案,找出最大的$i \times 10^6 \leq N$后,剩余部分用Miller Rabin素数测试暴力判断即可。
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn=;
const int tim=;
int ans[]={,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,};
bool ispl[maxn],ispr[maxn];
ll pow(ll a,ll b,ll mod){
int ans=;
while(b){
if(b&) ans=(ans*a)%mod;
a=(a*a)%mod;
b>>=;
}
return ans;
}
bool isp(ll n){
int i,j,t;
ll a,x,y,u;
if(n==)return true;
if(n<||!(n&)) return false;
t=,u=n-;
while((u&)==)t++,u>>=;
for(i=;i<=tim;i++){
a=rand()%(n-)+;
x=pow(a,u,n);
for(j=;j<t;j++){
y=(x*x)%n;
if(y==&&x!=&&x!=n-)return false;
x=y;
}
if(x!=)return false;
}
return true;
}
int main()
{
freopen("brothers.in","r",stdin);
freopen("brothers.out","w",stdout);
int l,r;
while(~scanf("%d%d",&l,&r)){
if(l+>r){
printf("0\n");
continue;
}
int resl=;
int resr=;
int tmpl=l/(int)1e6;
int tmpr=r/(int)1e6;
memset(ispl,,sizeof(ispl));
memset(ispr,,sizeof(ispr));
int tl=max(tmpl*(int)1e6-+,);
int tr=max(tmpr*(int)1e6-+,);
for(int i=tl;i<l+;i++){
ispl[i-tl]=isp((ll)i);
}
for(int i=tl;i<l;i++){
if(ispl[i-tl]&&ispl[i-tl+])
resl++;
}
resl+=ans[tmpl];
for(int i=tr;i<=r;i++){
ispr[i-tr]=isp((ll)i);
}
for(int i=tr;i<=r-;i++){
if(ispr[i-tr]&&ispr[i-tr+])
resr++;
}
resr+=ans[tmpr];
printf("%d\n",resr-resl);
}
}
D-Domino
#include <iostream>
#include <algorithm>
#include <cstring>
#include <stdio.h>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <iomanip>
using namespace std;
const int N=1e4+;
int a[N],b[N];
int main()
{
freopen("domino.in","r",stdin);
freopen("domino.out","w",stdout);
int n,r,sum=,ans=;
int x,y;
scanf("%d%d",&n,&r);
for(int i=;i<=n;i++){
scanf("%d%d",&a[i],&b[i]);
sum+=a[i]+b[i];
}
int rr;
for(int i=;i<=*r;i++){
scanf("%d",&rr);
if(i==)x=rr;
if(i==*r)y=rr;
}
if(n==){
if(a[]==x||a[]==y||b[]==x||b[]==y){
printf("%d",-);
return ;
}
}
if(n==){
if(a[]==b[]&&a[]==b[])
if((a[]==x&&a[]==y)||(a[]==y&&a[]==x)){
printf("%d",-);
return ;
}
}
int flag1=,flag2=;
for(int i=;i<=n;i++)
{
if(a[i]==b[i]){
if(flag1==&&a[i]==x)
flag1=;
else if(flag2==&&a[i]==y)
flag2=;
}
if(a[i]==x||a[i]==y||b[i]==x||b[i]==y)
ans=max(a[i]+b[i],ans);
}
if(flag1&&flag2)
ans=max(x+x+y+y,ans);
printf("%d",sum-ans);
}
E-Express Lines
题目大意:在一个有 $N$个点的环上选择不少于$2$个点,而且选择的点不相邻,求方案数。
题解:拆换成链,$f[i][0/1][0/1]$表示前$i$个点是否选择第$1$个点,是否选择第$i$个点的方案数。
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
long long mod;
long long f[][][];
int main()
{
int i;
freopen("express.in","r",stdin);
freopen("express.out","w",stdout);
scanf("%d%lld",&n,&mod);
f[][][]=(long long);
f[][][]=(long long);
f[][][]=(long long);
f[][][]=(long long);
for(i=;i<=n;i++)
{
f[i][][]=(f[i-][][]+f[i-][][])%mod;
f[i][][]=f[i-][][]%mod; f[i][][]=(f[i-][][]+f[i-][][])%mod;
f[i][][]=f[i-][][];
}
if(n<=) printf("");
else printf("%lld",(f[n][][]+f[n][][]+f[n][][]-(long long)n-(long long)+mod*(n/mod+))%mod);
return ;
}
G-Game
题目大意:有m个球,每个球上有两个按钮,一个对应蓝色,一个对应红色,但不知道哪个按钮对应哪种颜色。现在以放回的方式依次取出两个球,记录按下的按钮对应的颜色,如果两个球选择的颜色相同,则赢,否则输。现在知道其中一个取出的球的编号不超过$k$,且这个球选择的颜色是蓝色,问赢的概率。
题解:设事件$A$为赢,$B$为其中一个取出的球的编号不超过$k$且这个球选择的颜色是蓝色。
$P(A|B)=\frac{P(AB)}{P(B)}=\frac{2(k)(m)-k^2}{2(k)(2m)-k^2}=\frac{2m-k}{4m-k}$
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std; int n;
double k,m,a,b; int main()
{
int i;
freopen("game.in","r",stdin);
freopen("game.out","w",stdout);
scanf("%d",&n);
for(i=;i<=n;i++)
{
scanf("%lf%lf",&k,&m);
a=1.0*(2.0*m-k);b=(4.0*m-k);
printf("%.11lf\n",a/b);
}
return ;
}
F-"Injurious" Triples
题目大意:在一个序列里面找出一个三个数的子序列满足这三个数按原顺序构成等差数列。
题解:暴力枚举两个数,判断另一个数是否存在。
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std; int n,lim;
int a[],f[];
void solve()
{
int i,j;
for(i=;i<=n;i++)
for(j=i+;j<=n;j++)
if(*a[j]-a[i]>=&&*a[j]-a[i]<=lim&&f[*a[j]-a[i]]>j)
{
puts("Yes");
printf("%d %d %d",i,j,f[*a[j]-a[i]]);
return;
} puts("No");
}
int main()
{
int i,j;
freopen("injurious.in","r",stdin);
freopen("injurious.out","w",stdout);
scanf("%d",&n);
for(i=;i<=n;i++)
scanf("%d",&a[i]);
lim=a[];
for(i=;i<=n;i++)
if(a[i]>lim) lim=a[i];
for(i=;i<=n;i++)
f[a[i]]=i;
solve();
return ;
}
M-Munich
题目大意:有三种日票,第一种是成人票,价格为$p_1$,第二种是儿童票,价格为$p_2$,但儿童也可以买成人票,第三种是团体票,最多可以有$5$个成人,一个成人可以换成$1$个或$2$个儿童,价格为$p_3$。还有三种三日票,跟普通日票一样,只是能用三日而已。现在有$m$个成人,$n$个儿童来玩$k(1 \leq k \leq 3)$天,问最少花费多少钱买票。
题解:$f[i][j]$表示已经购买了$i$个成人票$j$个儿童票的最小花费。
【GYM101409】2010-2011 ACM-ICPC, NEERC, Western Subregional Contest的更多相关文章
- 2018-2019 ICPC, NEERC, Southern Subregional Contest
目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...
- Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest
2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...
- 2009-2010 ACM-ICPC, NEERC, Western Subregional Contest
2009-2010 ACM-ICPC, NEERC, Western Subregional Contest 排名 A B C D E F G H I J K L X 1 0 1 1 1 0 1 X ...
- 【转】lonekight@xmu·ACM/ICPC 回忆录
转自:http://hi.baidu.com/ordeder/item/2a342a7fe7cb9e336dc37c89 2009年09月06日 星期日 21:55 初识ACM最早听说ACM/ICPC ...
- 【*2000】【2018-2019 ICPC, NEERC, Southern Subregional Contest C 】Cloud Computing
[链接] 我是链接,点我呀:) [题意] [题解] 我们可以很容易知道区间的每个位置有哪些安排可以用. 显然 我们优先用那些花费的钱比较少的租用cpu方案. 但一个方案可供租用的cpu有限. 我们可以 ...
- Codeforces1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)总结
第一次打ACM比赛,和yyf两个人一起搞事情 感觉被两个学长队暴打的好惨啊 然后我一直做傻子题,yyf一直在切神仙题 然后放一波题解(部分) A. Find a Number LINK 题目大意 给你 ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror) Solution
从这里开始 题目列表 瞎扯 Problem A Find a Number Problem B Berkomnadzor Problem C Cloud Computing Problem D Gar ...
- codeforce1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) 题解
秉承ACM团队合作的思想懒,这篇blog只有部分题解,剩余的请前往星感大神Star_Feel的blog食用(表示男神汉克斯更懒不屑于写我们分别代写了下...) C. Cloud Computing 扫 ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)
A. Find a Number 找到一个树,可以被d整除,且数字和为s 记忆化搜索 static class S{ int mod,s; String str; public S(int mod, ...
随机推荐
- Mysql数据库日志类型查询与配置详解
在mysql中日志分为很多种,下面小编来给大家介绍Mysql数据库日志类型查询与使用,希望对各位同学会有所帮助 mysql常见的日志类型有五种:错误日志.二进制日志.查询日志.慢查日志和中继日志. 一 ...
- python 异常层级
- JAVA代码规范 标签: java文档工作 2016-06-12 21:50 277人阅读 评论(5) 收藏
开始做java的ITOO了,近期的工作内容就是按照代码规范来改自己负责的代码,之前做机房收费系统的时候,也是经常验收的,甚至于我们上次验收的时候,老师也去了.对于我们的代码规范,老师其实是很重视的,他 ...
- Libevent:9Evbuffers缓存IO的实用功能
Libevent的evbuffer功能实现了一个字节队列,优化了在队列尾端增加数据,以及从队列前端删除数据的操作. Evbuffer用来实现缓存网络IO中的缓存部分.它们不能用来在条件发生时调度IO或 ...
- ELK2之ELK的语法学习
1.回顾 (1)es是什么? es是基于Apache Lucene的开源分布式(全文)搜索引擎,提供简单的RESTful API来隐藏Lucene的复杂性. es除了全文搜索引擎之外,还可以这样描述它 ...
- python 数据的写入
- uva 11754 Code Feat (中国剩余定理)
UVA 11754 一道中国剩余定理加上搜索的题目.分两种情况来考虑,当组合总数比较大的时候,就选择枚举的方式,组合总数的时候比较小时就选择搜索然后用中国剩余定理求出得数. 代码如下: #includ ...
- SuperSocket SuperWebSocket并发数100限制的问题
var wsSer = new WebSocketServer(); wsSer.NewMessageReceived += wsSer_NewMessageReceived;//有消息传入时事件 w ...
- PyCharm indexing goes into infinite loop pycharm 不同的indexing
https://stackoverflow.com/questions/24955896/pycharm-indexing-goes-into-infinite-loop 5 1 I opened u ...
- 浏览器间CSS样式兼容问题
1.display:table居中显示 在chrome和safari浏览器上兼容问题 2.滤镜 在chrome浏览器中能正常显示,在360浏览器中不能正常显示 3.省略号问题 对于一行显示,基本上对所 ...