HDU 4473 Exam 枚举】的更多相关文章

原题转化为求a*b*c <=n中选出两个数组成有序对<a,b>的选法数. 令a<=b<=c.... 分情况讨论: (1)全部相等,即a = b = c. 选法有n^(1/3). (2)有两个相等,则设相等的值为i,枚举i = 1到i*i <= n ,剩下的一个数的最大值为t = n/(i*i).当t >=i时,t = i这一种要删除,因为t = i则三个数都相等了,这种选法有3种,所以ans += 3*(t-1).t<i就ans += 3*t; (3)三个数…
思路: 将条件转化为满足abc<=n的abc的数目. 1.3个数相等时,为 A; 2.有2个数相等时,为 B; 3.都不相等时,为 C. 则结果为A+3*B+6*C. 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #include<vecto…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2489 思路:由于N, M的范围比较少,直接枚举所有的可能情况,然后求MST判断即可. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <vector> using namespac…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3118 思路:题目要求是去掉最少的边使得图中不存在路径长度为奇数的环,这个问题等价于在图中去掉若干条边,使得这个图成为二分图.注意到n不是很大,于是我们可以想到二进制枚举,枚举每条边的两个顶点是否在同一个集合中,若是,则删除这条边. #include<iostream> #include<cstdio> #include<cstring> #include<algori…
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=4473 题目意思 定义f(x) = 满足(a * b)|x的有序对(a,b)的个数. 然后输入一个n,求f(1) + f(2) + ... + f(n) 废话不多说,此题的关键在于: 把原题的条件(a * b)|x 转化为 a * b * y = x 然后就很好计算了,就是,输入一个n,计算有多少有序对(a, b ,y)满足a*b*y<=n 不妨设a<=b<=y 则,a<=n^(1/3…
Beautiful Now Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1876    Accepted Submission(s): 707 Problem Description Anton has a positive integer n, however, it quite looks like a mess, so he…
Problem Description === Op tech briefing, 2002/11/02 06:42 CST === "The item is locked in a Klein safe behind a painting in the second-floor library. Klein safes are extremely rare; most of them, along with Klein and his factory, were destroyed in Wo…
The 2015 ACM-ICPC China Shanghai Metropolitan Programming Contest 2015ACM-ICPC上海大都会赛 签到题 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; +; struct Exam { int r,e,l; int Start,End; }E[maxn…
<题目链接> Problem Description 小希和Gardon在玩一个游戏:对一个N*M的棋盘,在格子里放尽量多的一些国际象棋里面的“车”,并且使得他们不能互相攻击,这当然很简单,但是Gardon限制了只有某些格子才可以放,小希还是很轻松的解决了这个问题(见下图)注意不能放车的地方不影响车的互相攻击. 所以现在Gardon想让小希来解决一个更难的问题,在保证尽量多的“车”的前提下,棋盘里有些格子是可以避开的,也就是说,不在这些格子上放车,也可以保证尽量多的“车”被放下.但是某些格子若…
Exam Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1944    Accepted Submission(s): 948 Problem Description As this term is going to end, DRD needs to prepare for his final exams. DRD has n exa…