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的更多相关文章

  1. 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 ...

  2. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...

  3. 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 ...

  4. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 关于自定义tabBar时修改系统自带tabBarItem属性造成的按钮顺序错乱的问题相关探究

      关于自定义tabBar时修改系统自带tabBarItem属性造成的按钮顺序错乱的问题相关探究 测试代码:http://git.oschina.net/Xiyue/TabBarItem_TEST 简 ...

  2. 【学习笔记】【C语言】变量的内存分析

    计算机中的内存是以字节为单位的存储空间.内存的每一个字节都有一个唯一的编号,这个编号就称为地址.就好像酒店是以房间为单位的,每个房间都有一个唯一的房号,我们根据房号就能找到对应的房间. 1. 变量的存 ...

  3. UI3_ViewController初步

    // // AppDelegate.m // UI3_ViewController初步 // // Created by zhangxueming on 15/6/30. // Copyright ( ...

  4. 10款基于HTML5+CSS3实现的超酷源码动画

    1.基于Bootstrap的jQuery登录表单 这是一款基于Bootstrap的登录表单,表单的外观自然不用说,沿用了Bootstrap的风格,非常漂亮.这款登录表单有一个经过CSS3处理过的头像图 ...

  5. 7 款令人赞叹的 HTML5 动画应用

    1.HTML5 3D图片阴影翻转动画 这是一款很酷的HTML5 3D动画特效,这款3D特效可以为你的图片增加阴影的效果,而且可以让图片在鼠标滑过的时候出现3D翻转的动画效果. 在线演示 源码下载 2. ...

  6. Silverlight引用WebService时取消对ServiceReferences.ClientConfig文件的依赖

    做过Silverlight项目的朋友都知道一般来说我们在Silverlight项目中都需要引用WebService或是WCF,引用的方式是在Visual Studio窗口中通过“添加服务引用”来添加引 ...

  7. 链接与ELF文件格式的复习

    在这里复习一下链接的知识: 什么是链接(linking):把源代码形成的模块独立编译后组装成一个整体的的过程叫做链接. 链接主要过程包括:地址和空间分配(address and storage all ...

  8. <Apache服务的搭建"三件套"《目录验证》《虚拟主机》《加密证书》>

    自己没事会整理一些小知识,复习原来的同时也帮助新手. vvvvvvvvvvvvv开启apache目录验证vvvvvvvvvvvvvv htpasswd -cm uers redhat  //redha ...

  9. Bootstrap Paginator 分页 demo.

    效果如下: 需要的引用以下内容 bootstrap2 http://cnbootstrap.com/ bootstrap-paginator v0.5 主页 http://bootstrappagin ...

  10. Silverlight形状、画笔、变换、图像处理、几何图形

    1.形状(Ellipse.Line.Path.Polygon.Polyline 和 Rectangle) <UserControl x:Class="SharpStudy.MainPa ...