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 ...
随机推荐
- OSPF多区域配置
1.配置三台路由器IP R1(config)#INTER S1/0 R1(config-if)#IP ADDress 192.1.12.1 255.255.255.0 R1(config-if)#no ...
- asp.net 下载Excel (数据流,不保存)--客户端
效果图: 前端页面 <html> <head> <title>Test For Excel</title> <script src="j ...
- Cocos移植到Android的一些问题-中文乱码问题
Android平台版本和设备碎片化很严重,因此从Win32平台移植到Android平台会有很多问题,下面是我们归纳的从Win32平台移植到Android平台遇到的一些问题.在Android平台中文乱码 ...
- Xcode - 方法注释插件
VVDocumenter-Xcode,自动生成注释,感觉比较方便的插件,分享下,应该很多人都知道= = 在 https://github.com/onevcat/VVDocumenter-Xcode ...
- BeanDefinition的Resource定位——2
1.FileSystemXmlApplicationContext的实现 public class FileSystemXmlApplicationContext extends AbstractXm ...
- shell脚本初识
#!/bin/bash(linux脚本环境的声明即解释器,该解释器为bash,位于根目录下的bin目录下) 变量的定义与赋值: 格式:变量名=变量值(无需声明变量类型) 变量的引用: 格式:$变量名 ...
- Entity Framework Code First 常用方法集成
using System; using System.Collections.Generic; using System.Data.Entity; using System.Linq; using S ...
- HBase多条件筛选查询方案
最近的项目需要使用Hbase做实时查询,由于Hbase只支持一级索引,也就是使用rowkey作为索引查询,所以对于多条件筛选查询的支持不够,在不建立二级索引的情况下,只能使用Hbase API中提供的 ...
- php 判断字符串在另一个字符串中位置
$email='user@example.com'; //定义字符串$result=strstr($email,'@'); //返回子字符串echo $result; / ...
- MySQL数据库主从复制
一.MySQ主从复制(主库写入数据,从库读取数据) MySql官方下载地址:http://dev.mysql.com/downloads/mysql/ MySql常用命令: 设置密码 UPDATE U ...