HDU重现赛之2019CCPC-江西省赛
本人蒟蒻,5个小时过了5道,看到好几个大佬AK,%%%%%%%
http://acm.hdu.edu.cn/contests/contest_show.php?cid=868
先放大佬的题解(不是我写的。。同学给的),能理解多少就靠你们自己了,还是希望大家能从大佬的题解中有所收获
口胡题解:
A. Co-Tree:由目标函数提到的两两距离和,可想到,在树上找个点,使得它到其它点距离和最小。
B. Math:考虑每秒开始时 “avin 拿着 Robot 在 i 点” 的状态 到 “Avin 拿着 Robot 在 i+1 点” 状态,需要时间 的期望?⼀一个状态自己转移到自己怎么办?
C. Trap:在互质这个限制条件,容斥!那么考虑没有互质的限制怎么做?枚举两条边,第三条边方案数怎么 快速统计?
D. Wave:枚举两种不同的数,复杂度多少?
E. Packing:我们需要决策,能 DP 吗?能贪心吗?按什么优先级来决定发哪个缓冲区的货呢?
F. String:乘法原理。
G. Traffic:哪些等待时间不合法?
H. Rng:for,for 枚举右端点可以做啊!观察两个 for 的做法,变成一个 for 就 win 了。
I. Buget:最低位决定答案。
J. Worker:按比例分配。
K. Class:解方程。
详细题解:
有些符号粘不出来,放截图吧,望见谅
有兴趣可以看看我过的题目(太蒻了,有点不好意思)
下面是题目:
1011 Class
Problem Description
Avin has two integers a, b (1 ≤ a, b ≤ 1, 000).
Given x = a + b and y = a - b, can you calculate a*b?
Input
The first line contains two integers x, y.
Output
Print the result of a*b.
Sample Input
Sample Output
签到题,直接粘代码
#include <stdio.h>
#include <algorithm> using namespace std; int main()
{
int a,b,x,y;
scanf("%d %d",&x,&y);
a=(x+y)/;
b=(x-y)/;
printf("%d\n",a*b);
return ;
}
1006 String
Problem Description
Avin has a string. He would like to uniform-randomly select four characters (selecting the same character is allowed) from it. You are asked to calculate the probability of the four characters being ”avin” in order.
Input
The first line contains n (1 ≤ n ≤ 100), the length of the string. The second line contains the string. To simplify the problem, the characters of the string are from ’a’, ’v’, ’i’, ’n’.
Output
Print the reduced fraction (the greatest common divisor of the numerator and denominator is 1), representing the probability. If the answer is 0, you should output "0/1".
Sample Input
avin aaaa
Sample Output
/
/
暴力过的,十分暴力
#include <stdio.h>
#include <algorithm> using namespace std; int gcd(int a,int b)
{
if(b==)
return a;
else return gcd(b,a%b);
} int main()
{
int n;
while(~scanf("%d",&n))
{
getchar();
char str[];
for(int i=;i<=n;i++)
{
str[i]=getchar();
}
int tot=;
int sum=;
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
for(int g=;g<=n;g++)
{
for(int k=;k<=n;k++)
{
tot++;
// if(i<j&&j<g&&g<k) //第一次wa的点,理解错题意了
// {
if(str[i]=='a'&&str[j]=='v'&&str[g]=='i'&&str[k]=='n')
sum++;
// }
}
}
}
}
if(sum!=)
{
int t=gcd(sum,tot);
// printf("sum=%d tot=%d t=%d\n",sum,tot,t);
printf("%d/%d\n",sum/t,tot/t);
}
else
printf("0/1\n");
}
return ;
}
1009 Budget
Problem Description
Avin’s company has many ongoing projects with different budgets. His company records the budgets using numbers rounded to 3 digits after the decimal place. However, the company is updating the system and all budgets will be rounded to 2 digits after the decimal place. For example, 1.004 will be rounded down
to 1.00 while 1.995 will be rounded up to 2.00. Avin wants to know the difference of the total budget caused by the update.
Input
The first line contains an integer n (1 ≤ n ≤ 1, 000). The second line contains n decimals, and the i-th decimal ai (0 ≤ ai ≤ 1e18) represents the budget of the i -th project. All decimals are rounded to 3 digits.
Output
Print the difference rounded to 3 digits..
Sample Input
1.001 0.999 1.001 0.999
Sample Output
-0.001
0.001
0.000
不管输入是不是三位小数了,我当做不是来写的,中间写的时候又有了新的想法,稍微改变了思路,所以29~35行有点乱,懒得改了,能过就直接交了
#include <stdio.h>
#include <string.h>
#include <algorithm> using namespace std; int main()
{
int n;
while(~scanf("%d",&n))
{
char str[];
double sum=;
for(int i=;i<n;i++)
{
double tem=;
scanf("%s",str);
int len=strlen(str);
int flag=;
int t=;
for(int i=;i<len;i++)
{
if(flag)
{
tem+=(str[i]-'')*1.0/t;
t*=;
continue;
}
if(str[i]!='.')
{
str[i]='';
}
else
{
flag=; if(str[i+])
str[i+]='';
else
break;
if(str[i+])
str[i+]='';
else break;
i+=;
}
}
if(tem<0.005)
sum-=tem;
else
sum+=0.01-tem;
}
if(sum<)
{
printf("-");
sum=-sum;
}
printf("%.3lf\n",sum);
}
return ;
}
1010 Worker
Problem Description
Avin meets a rich customer today. He will earn 1 million dollars if he can solve a hard problem. There are n warehouses and m workers. Any worker in the i-th warehouse can handle ai orders per day. The customer wonders whether there exists one worker assignment method satisfying that every warehouse handles the same number of orders every day. Note that each worker should be assigned to exactly one warehouse and no worker is lazy when working.
Input
The first line contains two integers n (1 ≤ n ≤ 1, 000), m (1 ≤ m ≤ 1018). The second line contains n integers. The i-th integer ai (1 ≤ ai ≤ 10) represents one worker in the i-th warehouse can handle ai orders per day.
Output
If there is a feasible assignment method, print "Yes" in the first line. Then, in the second line, print n integers with the i-th integer representing the number of workers assigned to the i-th warehouse.
Otherwise, print "No" in one line. If there are multiple solutions, any solution is accepted.
Sample Input
Sample Output
Yes No
根据比例分配的问题,这个long long就很烦,一直在卡我,注意1018是1018,十分无语
#include <stdio.h>
#include <string.h>
#include <algorithm> using namespace std;
typedef long long LL;
LL n,m; int gcd(LL a,LL b)
{
if(b==) return a;
else return gcd(b,a%b);
} int lcm(LL a,LL b)
{
return (a/gcd(a,b) )*b;
} int main()
{
while(~scanf("%lld %lld",&n,&m))
{
LL a[];
LL t[];
LL w[];
LL z=;
for(LL i=;i<=n;i++)
{
scanf("%lld",&a[i]);
z=lcm(max(z,a[i]),min(z,a[i]));
}
// printf("z=%lld\n",z);
LL sum=;
for(LL i=;i<=n;i++)
{
t[i]=z/a[i];
sum+=t[i];
// printf("t[%d]=%d,sum=%d\n",i,t[i],sum);
}
if(m%sum!=)
{
printf("No\n");
continue;
}
printf("Yes\n");
LL g=m/sum;
// printf("g=%d\n",g);
for(LL i=;i<=n;i++)
{
if(i==)
printf("%lld",t[i]*g);
else
printf(" %lld",t[i]*g);
}
printf("\n");
}
return ;
}
1007 Traffic
Problem Description
Avin is observing the cars at a crossroads. He finds that there are n cars running in the east-west direction with the i-th car passing the intersection at time ai . There are another m cars running in the north-south direction with the i-th car passing the intersection at time bi . If two cars passing the intersections at the same time, a traffic crash occurs. In order to achieve world peace and harmony, all the cars running in the north-south direction wait the same amount of integral time so that no two cars bump. You are asked the minimum waiting time.
Input
The first line contains two integers n and m (1 ≤ n, m ≤ 1, 000). The second line contains n distinct integers ai (1 ≤ ai ≤ 1, 000). The third line contains m distinct integers bi (1 ≤ bi ≤ 1, 000).
Output
Print a non-negative integer denoting the minimum waiting time.
Sample Input
Sample Output
这个刚开始有点不理解车是怎样个等法,后来见好多人都交了,我就按照我自己的理解去写了,直接AC了,真好,就是感觉这种等法太反人类了
#include <stdio.h>
#include <string.h>
#include <algorithm> using namespace std;
int n,m; int main()
{
while(~scanf("%d %d",&n,&m))
{
int a[]={};
int b[]={};
for(int i=;i<n;i++)
{
int t;
scanf("%d",&t);
a[t]=;
}
for(int i=;i<m;i++)
{
int t;
scanf("%d",&t);
b[t]=;
}
int p=;
while()
{
int flag=;
for(int i=;i<;i++)
{
if(b[i])
{
if(a[i+p])
{
flag=;
break;
}
}
}
if(flag)
{
break;
}
p++;
}
printf("%d\n",p);
}
return ;
}
船新版本
int main()
{
while(~scanf("%d %d",&n,&m))
{
int a[]={};
int b[]={};
for(int i=;i<n;i++)
{
int t;
scanf("%d",&t);
a[t]=;
}
for(int i=;i<m;i++)
{
scanf("%d",&b[i]);
}
int p=;
for(int i=;i<m;i++)
{ if(a[b[i]+p])
{
p++;
i=-;
}
}
printf("%d\n",p);
}
return ;
}
除了AC的5题,我和队友还尝试了Wave和Rng。Wave懂题意了,但不会做,Rng很简单,有快200人过了没读懂题,只能猜、猜、猜、菜、菜、菜。。。。
最后说一句RNGNB!!!
HDU重现赛之2019CCPC-江西省赛的更多相关文章
- HDU 5531 Rebuild (2015长春现场赛,计算几何+三分法)
Rebuild Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total S ...
- 2021江西省赛线下赛赛后总结(Crypto)
2021江西省赛线下赛 crypto1 题目: from random import randint from gmpy2 import * from Crypto.Util.number impor ...
- 52-2018 蓝桥杯省赛 B 组模拟赛(一)java
最近蒜头君喜欢上了U型数字,所谓U型数字,就是这个数字的每一位先严格单调递减,后严格单调递增.比如 212212 就是一个U型数字,但是 333333, 9898, 567567, 313133131 ...
- 天池新人赛-天池新人实战赛o2o优惠券使用预测(一)
第一次参加天池新人赛,主要目的还是想考察下自己对机器学习上的成果,以及系统化的实现一下所学的东西.看看自己的掌握度如何,能否顺利的完成一个分析工作.为之后的学习奠定基础. 这次成绩并不好,只是把整个机 ...
- 2019CCPC网络赛 C - K-th occurrence HDU - 6704(后缀数组+ST表+二分+主席树)
题意 求区间l,r的子串在原串中第k次出现的位置. 链接:https://vjudge.net/contest/322094#problem/C 思路 比赛的时候用后缀自动机写的,TLE到比赛结束. ...
- 2019CCPC网络赛 HDU 6702——找规律
题意 给定 $A,B$(都是正整数),求使得 $(A\ xor\ C) \& (B \ xor \ C)$ 最小的正整数 $C$,如果有多个满足条件的 $C$,输出最小的 $C$. 分析 ...
- HDU 5510 Bazinga (2015沈阳现场赛,子串判断)
Bazinga Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- HDU 5512 Pagodas (2015沈阳现场赛,找规律+gcd)
Pagodas Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- HDU 6212 Zuma 2017青岛网络赛 区间DP
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6212 解法:看了眼题就发现这个BZOJ 1032不是一毛一样?但是BZOJ上那是个巨坑,数据有错,原来 ...
随机推荐
- HDU - 2602 Bone Collector(01背包讲解)
题意:01背包:有N件物品和一个容量为V的背包.每种物品均只有一件.第i件物品的费用是volume[i],价值是value[i],求解将哪些物品装入背包可使价值总和最大. 分析: 1.构造二维数组: ...
- 数据类型和C#关系对应
sqlserver与c#中数据类型的对应关系///private string changetocsharptype(string type){string reval=string.empty;sw ...
- 【新年呈献】高性能网络通信框架 HP-Socket v5.7.1
项目主页 : http://www.oschina.net/p/hp-socket 开发文档 : https://www.docin.com/p-2287339564.html 下载地址 : http ...
- QSignalMapper is deprecated
今天参考 qt4 的书籍,在 qt5 的平台上面,用了 QSignalMapper,结果收到警告" QSignalMapper is deprecated". 经过一番查找,找到了 ...
- 吴裕雄--天生自然C++语言学习笔记:C++ 变量类型
变量其实只不过是程序可操作的存储区的名称.C++ 中每个变量都有指定的类型,类型决定了变量存储的大小和布局,该范围内的值都可以存储在内存中,运算符可应用于变量上. 变量的名称可以由字母.数字和下划线字 ...
- Hibernate(二)——一对多查询
1. 前言 本章节我们讨论Hibernate一对多查询的处理. 在上一章节中(Hibernate(一)——入门),我们探讨了Hibernate执行最基本的增删改查操作.现在我们将情况复杂化:加入我们在 ...
- Codeforces Round #594 (Div. 1) Ivan the Fool and the Probability Theory
题意:给你一个NxM的图,让你求有多少符合 “一个格子最多只有一个同颜色邻居”的图? 题解:首先我们可以分析一维,很容易就可以知道这是一个斐波那契计数 因为dp[1][m]可以是dp[1][m-1]添 ...
- 对比Node.js和Python 帮你确定理想编程解决方案!
世上没有最好的编程语言.有些编程语言比其他编程语言用于更具体的事情.比如,你可能需要移动应用程序,网络应用程序或更专业化的系统,则可能会有特定的语言.但是我们暂时假设你需要的是一个相对来说比较简单的网 ...
- (转载)(DescriptionResource Path Location Type The superclass "javax.servlet.http.HttpServlet" was not foun
eclipse环境下如何配置tomcat 打开Eclipse,单击"Window"菜单,选择下方的"Preferences". 单击"Server&q ...
- springboot跨域请求接口示例
一.项目架构 二.项目内容 1.GlobalCrosConfig.java package com.config; import org.springframework.context.annotat ...