这个估计是里面第二简单的了,因为第一简单的是求a+b 哈哈,一submit就ac了 题目如下: Description How far can you make a stack of cards overhang a table? If you have one card, you can create a maximum overhang of half a card length. (We're assuming that the cards must be perpendicular to…
Description There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo w…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1326 题目大意: 给n堵墙,每个墙的高度不同,求最少移动多少块转使得墙的的高度相同. 解题思路: 找到平均墙的高度(即最后墙的高度),遍历所有墙,如果小于平均墙,则用平均墙减去高度即是要移动的高度,统计所有需要"补"的高度即可.注意输出. AC Code: #include<bits/stdc++.h> using namespace std; int main() { ; w…
Road Construction Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10141   Accepted: 5031 Description It's almost summer time, and that means that it's almost summer construction time! This year, the good people who are in charge of the r…
题目: 输入一个数字n  如果n为偶数则除以2,若为奇数则加1或者减1,直到n为1,求最少次数  写出一个函数 首先,这道题肯定可以用动态规划来解, n为整数时,n的解为 n/2 的解加1 n为奇数时,n的解为 (n+1)/2 和 (n-1)/2 的解中较小的解加2 通过这个思路,我们可以自底向上依次计算出n的解,代码如下 public static int getNum(int n) { if(n<1) { return 0; } int[] res = new int[n+1]; res[0…
PKU OJ 1002 487-3279 487-3279 Description Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phrase. For example, you can call the University of Waterloo by dialin…
[题目] Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers. Note: All numbers will be positive integers. The solution set must not…
我的第一篇博客..  还不会什么高端的东西就来点基础的. 不用sizeof求int的bit数 //不用sizeof求int的bit数 #include<stdio.h> int main(){ unsigned int i = 1; int n = 0; while(i!=0){ i*=2; n++; } printf("%d\n",n); return 0;}…
题意:求一个无向图的,去掉两个不同的点后最多有几个连通分量. 思路:枚举每个点,假设去掉该点,然后对图求割点后连通分量数,更新最大的即可.算法相对简单,但是注意几个细节: 1:原图可能不连通. 2:有的连通分量只有一个点,当舍去该点时候,连通分量-1: 复习求割点的好题! #include<iostream> #include<cstdio> #include<vector> using namespace std; int n,m; vector<vector&…
功能: 求一个byte数字对应的二进制数字中1的最大连续数,例如3的二进制为00000011,最大连续2个1    输入: 一个byte型的数字    输出: 无     返回: 对应的二进制数字中1的最大连续数 package test; import java.util.Scanner; /* * 求最大连续bit数 * 功能: 求一个byte数字对应的二进制数字中1的最大连续数,例如3的二进制为00000011,最大连续2个1 * 输入: 一个byte型的数字 * 输出: 无 * 返回:…