The 10th Zhejiang Provincial Collegiate Programming Contest
Applications http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5008
string set 专场
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<set>
#define mt(a,b) memset(a,b,sizeof(a))
using namespace std;
const double eps=1e-;
const int M=;
set<int> A,B;
set<string> xiaosai[];
int defen[]={,,,};
char op[];
struct G{
double val;
string name;
friend bool operator <(const G &a,const G &b){
return a.val>b.val||(fabs(a.val-b.val)<eps&&a.name<b.name);
}
}p[];
int pri[M],mark[M],pricnt;//mark[i]存i的最小因子,素数时mark[i]==i
void sieve_primes() { //筛素数
pricnt=;
mt(mark,);
mark[]=mark[]=;
for(int i=; i<M; i++) {
if(!mark[i]) pri[pricnt++]=mark[i]=i;
for(int j=; pri[j]*i<M; j++) {
mark[i*pri[j]]=pri[j];
if(!(i%pri[j])) break;
}
}
}
int rat[];
int main(){
sieve_primes();
int t,n,m,q,c,tmp,id;
while(~scanf("%d",&t)){
while(t--){
scanf("%d%d%d",&n,&m,&q);
A.clear();
while(q--){
scanf("%d",&tmp);
A.insert(tmp);
}
scanf("%d",&q);
B.clear();
while(q--){
scanf("%d",&tmp);
B.insert(tmp);
}
scanf("%d",&q);
for(int i=;i<;i++){
xiaosai[i].clear();
}
while(q--){
scanf("%s%d",op,&id);
xiaosai[id].insert((string)op);
}
for(int i=;i<n;i++){
p[i].val=;
scanf("%s",op);
p[i].name=(string)op;
scanf("%s",op);
for(int j=;j<=;j++){
if(xiaosai[j].count((string)op)){
p[i].val+=defen[j];
break;
}
}
scanf("%s",op);
if(op[]=='F') p[i].val+=;
scanf("%d%d",&q,&c);
while(q--){
scanf("%d",&tmp);
if(A.count(tmp)){
p[i].val+=2.5;
continue;
}
if(B.count(tmp)){
p[i].val+=1.5;
continue;
}
if(mark[tmp]==tmp){
p[i].val+=;
continue;
}
p[i].val+=0.3;
}
for(int j=;j<c;j++){
scanf("%d",&rat[j]);
}
sort(rat,rat+c);
if(c>){
p[i].val+=max(0.0,(rat[c-]-1200.0)/100.0)*1.5;
}
}
sort(p,p+n);
for(int i=;i<m;i++){
cout<<p[i].name;
printf(" %.3f\n",p[i].val);
}
}
}
return ;
}
Break Standard Weight http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5009
set
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;
set<int> my;
int solve(int x,int y){
int res=;
for(int i=;i+i<=x;i++){
my.clear();
int a=i,b=x-i,c=y;
my.insert(a);
my.insert(b);
my.insert(c);
my.insert(abs(a+b));
my.insert(abs(a-b));
my.insert(abs(a+c));
my.insert(abs(a-c));
my.insert(abs(b+c));
my.insert(abs(b-c));
my.insert(abs(a+b+c));
my.insert(abs(a+b-c));
my.insert(abs(a-b+c));
my.insert(abs(a-b-c));
my.erase();
int cnt=my.size();
res=max(res,cnt);
}
return res;
}
int main(){
int t,x,y;
while(~scanf("%d",&t)){
while(t--){
scanf("%d%d",&x,&y);
printf("%d\n",max(solve(x,y),solve(y,x)));
}
}
return ;
}
Density of Power Network http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5011
set
#include<cstdio>
#include<set>
using namespace std;
const int M=;
struct P{
int x,y;
friend bool operator <(const P &a,const P &b){
return a.x<b.x||(a.x==b.x&&a.y<b.y);
}
}p[M];
set<P> my;
int main(){
int t,n,m;
while(~scanf("%d",&t)){
while(t--){
scanf("%d%d",&n,&m);
for(int i=;i<m;i++){
scanf("%d",&p[i].x);
}
for(int i=;i<m;i++){
scanf("%d",&p[i].y);
}
my.clear();
for(int i=;i<m;i++){
if(p[i].x>p[i].y) swap(p[i].x,p[i].y);
my.insert(p[i]);
}
printf("%.3f\n",my.size()*1.0/n);
}
}
return ;
}
Friends http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5013
暴力加边
#include<cstdio>
#include<cstring>
#define mt(a,b) memset(a,b,sizeof(a))
const int M=;
bool mat[M][M];
void add(int u,int v){
mat[u][v]=mat[v][u]=true;
}
int main(){
int t,n,m,K,u,v;
while(~scanf("%d",&t)){
while(t--){
scanf("%d%d%d",&n,&m,&K);
mt(mat,);
while(m--){
scanf("%d%d",&u,&v);
add(u,v);
}
int ans=;
bool flag=true;
while(flag){
flag=false;
for(int i=;i<n;i++){
for(int j=i+;j<n;j++){
if(!mat[i][j]){
int sum=;
for(int k=;k<n;k++){
if(k!=i&&k!=j&&mat[i][k]&&mat[k][j]){
sum++;
}
}
if(sum>=K){
ans++;
flag=true;
add(i,j);
}
}
}
}
}
printf("%d\n",ans);
}
}
return ;
}
Hard to Play http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5015
求最大最小值
#include<cstdio>
int solve(int point,int times,int &combo){
int res=;
for(int i=;i<times;i++,combo++){
res+=point*(combo*+);
}
return res;
}
int main(){
int t,a,b,c,combo,big,sma;
while(~scanf("%d",&t)){
while(t--){
scanf("%d%d%d",&a,&b,&c);
combo=sma=;
sma+=solve(,a,combo);
sma+=solve(,b,combo);
sma+=solve(,c,combo);
combo=big=;
big+=solve(,c,combo);
big+=solve(,b,combo);
big+=solve(,a,combo);
printf("%d %d\n",sma,big);
}
}
return ;
}
In 7-bit http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5016
注意la==0
#include<cstdio>
#include<cstring>
const int M=;
char a[M];
int main(){
int t;
while(~scanf("%d",&t)){
getchar();
while(t--){
gets(a);
int la=strlen(a);
if(la==){
puts("");
continue;
}
int len=la;
while(len>){
int now=len%;
len/=;
if(len) now|=;
printf("%02X",now);
}
for(int i=;i<la;i++){
printf("%02X",a[i]);
}
puts("");
}
}
return ;
}
Java Beans http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5017
n个人坐成环,求连续m个和最大
#include<cstdio>
#include<algorithm>
using namespace std;
const int M=;
int a[M];
int main(){
int t,n,m;
while(~scanf("%d",&t)){
while(t--){
scanf("%d%d",&n,&m);
for(int i=;i<n;i++){
scanf("%d",&a[i]);
a[i+n]=a[i];
}
int ans=;
for(int i=;i<n;i++){
int sum=;
for(int j=;j<m;j++){
sum+=a[i+j];
}
ans=max(ans,sum);
}
printf("%d\n",ans);
}
}
return ;
}
end
The 10th Zhejiang Provincial Collegiate Programming Contest的更多相关文章
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Demacia of the Ancients
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5504 The 12th Zhejiang Provincial ...
- zjuoj The 12th Zhejiang Provincial Collegiate Programming Contest Ace of Aces
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5493 The 12th Zhejiang Provincial ...
- 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第二部分)
Floor Function Time Limit: 10 Seconds Memory Limit: 65536 KB a, b, c and d are all positive int ...
随机推荐
- iOS开发中遇到的头文件找不到的问题解决办法
有时会遇到莫名其妙的明明有这个文件,但是就是显示头文件找不到,我也是咨询了技术大牛之后知道的这个方法,之后恰巧我一个朋友问我cocoapod加进去之后头文件找不到,我就让他试了下这个方法果然好用,我也 ...
- 【学习笔记】【C语言】变量类型
根据变量的作用域,可以分为: 1.局部变量: 1> 定义:在函数(代码块)内部定义的变量(包括函数的形参) 2> 作用域:从定义变量的那一行开始,一直到代码块结束 3> 生命周期:从 ...
- POJ 1273(EK)
题目大概意思是,有N条水沟和M个水池,问从第一个水池到最后一个水池在同一时间内能够流过多少水第一行有两个整数N,M接下来N行,每行有3个整数,a,b,c,代表从a到b能够流c单位的水超级模板题,一个有 ...
- 简明Python中的一个小错误
最近在学Python,先看的是<Python基础教程>,后来经别人推荐,感觉网络上的<简明Python教程>也挺好的,在里面发现一个小错误. 网址如下:http://sebug ...
- 《postfix MAIL服务搭建(第一篇):》RHEL6
初级篇:搭建发送端.接收端.邮件别名的添加从而达到邮件群发功能的实现. 我们都知道邮件服务器是2个服务端也就是说2个端口,一个是发送的端口,一个是收邮件的端口,我们平常所使用的发送,接收邮件的过程,只 ...
- git 的使用(4)-git暂缓区工作区原理和修改删除等命令
文章转载自:http://blog.csdn.net/think2me/article/details/39056379 博主说未经本人允许,不得转载,那就不贴了,拷贝关键部分作备忘 1. 暂存区是G ...
- [大牛翻译系列]Hadoop(11)MapReduce 性能调优:诊断一般性能瓶颈
6.2.4 任务一般性能问题 这部分将介绍那些对map和reduce任务都有影响的性能问题. 技术37 作业竞争和调度器限制 即便map任务和reduce任务都进行了调优,但整个作业仍然会因为环境原因 ...
- Oracle 表的连接方式(2)-----HASH JOIN的基本机制2
Hash算法原理 对于什么是Hash算法原理?这个问题有点难度,不是很好说清楚,来做一个比喻吧:我们有很多的小猪,每个的体重都不一样,假设体重分布比较平均(我们考虑到公斤级别),我们按照体重来分,划分 ...
- [转]Linux中find常见用法示例
Linux中find常见用法示例[转]·find path -option [ -print ] [ -exec -ok command ] {} \;find命令的参 ...
- C# 命名参数【转】
命名参数(Named Arguments)就是说在调用函数时可以通过指定参数名称的方式来调用参数.它最大的好处就是方便调用参数时按调用者的需要来排列顺序,而不必死守函数声明时的顺序(相对于“位置参数” ...