BC 两道其实都是水 没有完整地想好直接就码出事情.wa了一次以后要找bug,找完要把思路理的非常清楚 SPOJ PHT[二分] #include<bits/stdc++.h> using namespace std; int main() { long long n; int T,CAS=1; scanf("%d",&T); while(T--) { scanf("%lld",&n); long long left=0; long lo…
Cyclic Tour Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/65535 K (Java/Others)Total Submission(s): 1197 Accepted Submission(s): 626 Problem Description There are N cities in our country, and M one-way roads connecting them. Now Li…
(上不了p站我要死了,侵权度娘背锅) Description 小 C 最近学了很多最小生成树的算法,Prim 算法.Kurskal 算法.消圈算法等等. 正当小 C 洋洋得意之时,小 P 又来泼小 C 冷水了.小 P 说,让小 C 求出一个无向图的次小生成树,而且这个次小生成树还得是严格次小的,也就是说: 如果最小生成树选择的边集是 EM,严格次小生成树选择的边集是 ES,那么需要满足: ∑value(e) (e∈EM)< ∑value(e)(e∈ES)(value(e) 表示边 e的权值) 这…
The k-th Largest Group Time Limit: 2000MS Memory Limit: 131072K Total Submissions: 8807 Accepted: 2875 Description Newman likes playing with cats. He possesses lots of cats in his home. Because the number of cats is really huge, Newman wants to g…
17.4 Write a method which finds the maximum of two numbers. You should not use if-else or any other comparison operator. 这道题让我们找出两个数中的较大值,不能用if..else..语句判断,也不能用任何比较符号.那么我们怎么办呢,我们看两个数的差值a-b是否大于0,如果大于0,说明a大,如果小于0,说明b大.然后我们用一个变量k来记录a-b的符号位,用q来表示k的相反数,这样…
题目链接: http://poj.org/problem?id=1797 Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has buil…
洛谷P4014 分配问题[最小/大费用流]题解+AC代码 题目描述 有 n 件工作要分配给 n 个人做.第 i 个人做第 j 件工作产生的效益为c ij. 试设计一个将 n 件工作分配给 n 个人做的分配方案,使产生的总效益最大. 输入格式: 文件的第 1 行有 1 个正整数 n,表示有 n 件工作要分配给 n 个人做.接下来的 n 行中,每行有 n 个整数c ij,表示第 i 个人做第 j 件工作产生的效益为c ij . 输出格式: 两行分别输出最小总效益和最大总效益. 输入样例 5 2 2…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2639 Bone Collector II Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5817 Accepted Submission(s): 3067 Problem Description The title of this…
//求出4×4矩阵中最大和最小元素值及其所在行下标和列下标,求出两条主对角线元素之和 #include <stdio.h> int main() { int sum=0; int max,min; int max1,max2;//记录最大值的坐标 int min1,min2;//记录最小值的坐标 int i,j; int a[4][4]; //为数组赋值 for(i=0;i<4;i++) { for(j=0;j<4;j++) { scanf("%d",&…
题目描述: In a given integer array nums, there is always exactly one largest element. Find whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of the largest element, otherwise…
传送门:http://poj.org/problem?id=3565 Ants Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 7650 Accepted: 2424 Special Judge Description Young naturalist Bill studies ants in school. His ants feed on plant-louses that live on apple tree…
传送门:http://poj.org/problem?id=2195 Going Home Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 26151 Accepted: 13117 Description On a grid map there are n little men and n houses. In each unit time, every little man can move one unit st…
Cyclic Tour Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/65535 K (Java/Others)Total Submission(s): 2399 Accepted Submission(s): 1231 Problem Description There are N cities in our country, and M one-way roads connecting them. Now L…
题意 : 给出一个含有 N 个数的序列,然后有 M 次问询,每次问询包含 ( L, R, K ) 要求你给出 L 到 R 这个区间的第 K 大是几 分析 : 求取区间 K 大值是个经典的问题,可以使用的方法有很多,我听过的只有主席树.整体二分法.划分树.分块…… 因为是看<挑战>书介绍的平方分割方法(分块),所以先把分块说了,其他的坑以后再填 分块算法思想是将区间分为若干块,一般分为 n1/2 块然后在每块维护所需信息,可以把复杂度降到 O(根号n) 具体的分析和代码在<挑战程序设计竞赛…