HDU-1036 Average is not Fast Enough!】的更多相关文章

thanks to http://stackoverflow.com/questions/2144459/using-scanf-to-accept-user-input and http://stackoverflow.com/questions/456303/how-to-validate-input-using-scanf for the i/o part. thanks to http://www.haodaima.net/art/137347 for the rounding part…
Average is not Fast Enough! http://acm.hdu.edu.cn/showproblem.php?pid=1036 Problem Description A relay is a race for two or more teams of runners. Each member of a team runs one section of the race. Your task is to help to evaluate the results of a r…
Problem Description A relay is a race for two or more teams of runners. Each member of a team runs one section of the race. Your task is to help to evaluate the results of a relay race. You have to process several teams. For each team you are given a…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5353 题意:有n个人围城一个环,每一个人手里都有一些糖果,第i个人有ai块.现在有三种操作:第i个人给第i+1个人一块.第i+1个人给第i个人一块.什么都不做.第i个人和第i+1个人之间,可以选择一种操作并执行,问最终能不能让所有人手里的糖相等. 解法:贪心. 当n = 1 时,永远是YES 当n = 2 时,注意1和2之间只能有一种操作,不存在循环. 当n > 2 时: 糖的总数不能均分到n个人手…
Average Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2069    Accepted Submission(s): 517Special Judge Problem Description There are n soda sitting around a round table. soda are numbered fr…
传送门 Average distance Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 682    Accepted Submission(s): 244Special Judge Problem Description Given a tree, calculate the average distance between two…
题意:有n个人坐在圆桌上,每个人带着糖果若干,每次只能给旁边的人1科糖果,而且坐相邻的两个人最多只能给一次(要么你给我,要么我给你),问是否能将糖果平均分了. 思路: 明显每个人最多只能多于平均值2个糖果,因为他只能分别往左和右边的人给1颗.而多于平均值1的人可以任意选1个方向,只要到最后所有人满足了即可.多余糖果超过3的.平均数是浮点型的都是无解. 求解步骤: 在第i和第i+1个人之间建两条边(即无向边拆成2条有向边),分别从一方指向另一方.1和n也建两条.分两步: (1)将持有2个多余糖果的…
题意描述很垃圾,后来看别人代码才知道怎么回事:对(题目所给d/总时间:所有时间加起来)四舍五入并取整,然后对结果/60得到用了几分钟:对结果%60得到用了几秒. presentation error一次,因为没注意到输出的队伍编号占3格,要用%3d 代码 #include<bits/stdc++.h> using namespace std; #define maxn 100 #define rep(i,a,b) for(int i=(a);i<(b);i++) #define ll l…
题意是求出跑了 n 圈每圈 m km 的个人的平均速度. 控制格式,特别注意,题意是输出 -:--:-- 的该人成绩作废,但要把他其他的成绩输进去,不能直接就 break ,输出也就只有一个 - ,而不是与作废圈数相等的 - . 代码如下: #include <bits/stdc++.h> using namespace std; int main() { int aa,bb,n,no; double s,sec; ]; bool f; scanf("%d%lf",&…
Problem Description There are n soda sitting around a round table. soda are numbered from 1 to n and i-th soda is adjacent to (i+1)-th soda, 1-st soda is adjacent to n-th soda. Each soda has some candies in their hand. And they want to make the numbe…
就是贪心啊,不知道为啥总是不过,总是WA 方法不对吗? 将数组扩展一倍,从左到右扫描,大于平均数就给右边的,小于就从右边拿,等于就不变,记录下操作类型. 大于2直接NO,不知道哪错了,自己出了一些数据也都过了 路过的大神多瞄一眼 多校每周只有两场,还是尽量把题全过了吧 #pragma comment(linker, "/STACK:102400000,102400000") #include <iostream> #include <cstdio> #inclu…
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093. 1094.1095.1096.1097.1098.1106.1108.1157.116…
 题目链接:Average is not Fast Enough! #include <iostream> #include <cstring> #include <string> #include <cstdio> using namespace std; int main() { int n, id; double d; cin>>n>>d; while (cin>>id) { printf("%3d: &q…
Average is not Fast Enough! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3436    Accepted Submission(s): 1348 Problem Description A relay is a race for two or more teams of runners. Each mem…
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY…
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1019 Grandpa's Other Estate 1034 Simple Arithmetics 1036 Complete the sequence! 1043 Maya Calendar 1054 Game Prediction 1057 Mileage Bank 1067 Rails 10…
序:这是一篇发表在2003年6月刊的MSDN Magazine的文章,现在已经不能在线阅读,只提供chm下载.讲的是异步请求处理那些事,正是我上一篇博文涉及的东西(BTW,事实上这篇杂志阐述了那么搞然并卵),期间有搜索到这篇文章,很受裨益.担心MS哪么时候不再提供下载以及本地保管不便,所以现在誊上来,作为备份,方便日后回顾. Fritz Onion This article assumes you're familiar with C#, ASP.NET, and MultithreadingL…
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.136 Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.000 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.198 Average Precision (AP)…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2993 Problem Description Consider a simple sequence which only contains positive integers as a1, a2 ... an, and a number k. Define ave(i,j) as the average value of the sub sequence ai ... aj, i<=j. Let’s…
MAX Average Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7639    Accepted Submission(s): 1667 Problem Description Consider a simple sequence which only contains positive integers as a…
Fast Food Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2173    Accepted Submission(s): 930 Problem Description The fastfood chain McBurger owns several restaurants along a highway. Recently,…
题目链接.hdu 4965 Fast Matrix Calculation 题目大意:给定两个矩阵A,B,分别为N*K和K*N. 矩阵C = A*B 矩阵M=CN∗N 将矩阵M中的全部元素取模6,得到新矩阵M' 计算矩阵M'中全部元素的和 解题思路:由于矩阵C为N*N的矩阵,N最大为1000.就算用高速幂也超时,可是由于C = A*B, 所以CN∗N=ABAB-AB=AC′N∗N−1B,C' = B*A, 为K*K的矩阵,K最大为6.全然能够接受. #include <cstdio> #inc…
题目链接:hdu 2993 MAX Average Problem 题意: 给一个长度为 n 的序列,找出长度 >= k 的平均值最大的连续子序列. 题解: 这题是论文的原题,请参照2004集训队论文<周源--浅谈数形结合思想在信息学竞赛中的应用> 这题输入有点大,要加读入优化才能过. #include<bits/stdc++.h> #define F(i,a,b) for(int i=a;i<=b;++i) using namespace std; int tot;…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2993 Consider a simple sequence which only contains positive integers as a1, a2 ... an, and a number k. Define ave(i,j) as the average value of the sub sequence ai ... aj, i<=j. Let’s calculate max(ave(i…
HDU 4965 Fast Matrix Calculation 题目链接 矩阵相乘为AxBxAxB...乘nn次.能够变成Ax(BxAxBxA...)xB,中间乘n n - 1次,这样中间的矩阵一个仅仅有6x6.就能够用矩阵高速幂搞了 代码: #include <cstdio> #include <cstring> const int N = 1005; const int M = 10; int n, m; int A[N][M], B[M][N], C[M][M], CC[N…
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1227 题意:一维坐标上有n个点,位置已知,选出k(k <= n)个点,使得所有n个点与选定的点中最近的点的距离总和最小,求出最小值. 思路: 将点i的距离记为为dis[i],从i到j选出一点使此段距离和最小,则此点坐标为dis[(i + j) / 2] cost[i][j]为从i到j选出一点距离和的最小值.则求cost[i][j]的代码如下: cost[i][j] = 0; for(int k =…
题目链接:hdu 4965,题目大意:给你一个 n*k 的矩阵 A 和一个 k*n 的矩阵 B,定义矩阵 C= A*B,然后矩阵 M= C^(n*n),矩阵中一切元素皆 mod 6,最后求出 M 中所有元素的和.题意很明确了,便赶紧敲了个矩阵快速幂的模板(因为编程的基本功不够还是调试了很久),然后提交后TLE了,改了下细节,加了各种特技,比如输入优化什么的,还是TLE,没办法,只好搜题解,看了别人的题解后才知道原来 A*B 已经是 n*n 的矩阵了,所以(A*B)n*n 的快速幂里的每个乘法都是…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3577 题意不好理解,给你数字k表示这里车最多同时坐k个人,然后有q个询问,每个询问是每个人的上车和下车时间,每个人按次序上车,问哪些人能上车输出他们的序号. 这题用线段树的成段更新,把每个人的上下车时间看做一个线段,每次上车就把这个区间都加1,但是上车的前提是这个区间上的最大值不超过k.有个坑点就是一个人上下车的时间是左闭右开区间,可以想到要是一个人下车,另一个人上车,这个情况下这个点的大小还是不变…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2993 题目大意:给定一个长度为n(最长为10^5)的正整数序列,求出连续的最短为k的子序列平均值的最大值. Sample Input 10 6 6 4 2 10 3 8 5 9 4 1   Sample Output 6.50 分析:斜率优化DP,要认真看 代码如下: # include<iostream> # include<cstdio> # include<cstring&…
MAX Average Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5803    Accepted Submission(s): 1433 Problem Description Consider a simple sequence which only contains positive integers as a…