07 2011 档案

Humble Numbers HDU 1058 ACM
摘要:Humble NumbersTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6085Accepted Submission(s): 2639Problem DescriptionA number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 阅读全文

posted @ 2011-07-31 21:43 kuangbin 阅读(3233) 评论(1) 推荐(2)

Rightmost Digit ACM HDU1061
摘要:Rightmost DigitTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12357Accepted Submission(s): 4773Problem DescriptionGiven a positive integer N, you should output the most right digit of N^N.InputThe input contains several test cases. The first line 阅读全文

posted @ 2011-07-31 20:50 kuangbin 阅读(3181) 评论(0) 推荐(1)

HangOver ACM HDU1056
摘要:#include<iostream>using namespace std;int main(){ int n; double sum; double len; while(cin>>len) { if(len==0)break; sum=0; n=0; while(sum<len) { n++; sum+=1.0/(n+1); } cout<<n<<" card(s)"<<endl; } return 0; } HangOverTime Limit: 2000/1000 MS (Java/Others)Me 阅读全文

posted @ 2011-07-31 19:52 kuangbin 阅读(971) 评论(0) 推荐(0)

ACM HDU 1048The Hardest Problem Ever
摘要:The Hardest Problem EverTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7298Accepted Submission(s): 3289Problem DescriptionJulius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In o 阅读全文

posted @ 2011-07-31 19:45 kuangbin 阅读(3531) 评论(0) 推荐(0)

ACM POJ 1037 Keep on Truckin'
摘要:Keep on Truckin'Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3435Accepted Submission(s): 2369Problem DescriptionBoudreaux and Thibodeaux are on the road again . . ."Boudreaux, we have to get this shipment of mudbugs to Baton Rouge by to 阅读全文

posted @ 2011-07-31 00:38 kuangbin 阅读(1137) 评论(0) 推荐(0)

ACM HDU 1032The 3n + 1 problem
摘要:The 3n + 1 problemTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8757Accepted Submission(s): 3196Problem DescriptionProblems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In 阅读全文

posted @ 2011-07-30 22:09 kuangbin 阅读(1026) 评论(0) 推荐(0)

ACM HDU 1029Ignatius and the Princess IV
摘要:Ignatius and the Princess IVTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32767 K (Java/Others)Total Submission(s): 6518Accepted Submission(s): 2325Problem Description"OK, you are not too bad, em... But you can never pass the next test." feng5166 says."I will tell you an o 阅读全文

posted @ 2011-07-30 21:40 kuangbin 阅读(3743) 评论(4) 推荐(2)

ACM HDU 1028Ignatius and the Princess III
摘要:Ignatius and the Princess IIITime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4680Accepted Submission(s): 3280Problem Description"Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says.& 阅读全文

posted @ 2011-07-30 21:02 kuangbin 阅读(2404) 评论(0) 推荐(0)

ACM HDU 1021Fibonacci Again
摘要:Fibonacci AgainTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 15017Accepted Submission(s): 7022Problem DescriptionThere are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).InputInput consists of a sequence 阅读全文

posted @ 2011-07-30 20:25 kuangbin 阅读(432) 评论(0) 推荐(0)

ACM POJ 1328Radar Installation
摘要:Radar InstallationTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 27114Accepted: 5912DescriptionAssume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on 阅读全文

posted @ 2011-07-30 12:01 kuangbin 阅读(2882) 评论(0) 推荐(0)

ACM POJ 2965 The Pilots Brothers' refrigerator
摘要:http://poj.org/problem?id=2965The Pilots Brothers' refrigeratorTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 10158Accepted: 3707Special JudgeDescriptionThe game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a refrigerator.There are 16 ha 阅读全文

posted @ 2011-07-30 10:49 kuangbin 阅读(891) 评论(0) 推荐(0)

ACM POJ 1753Flip Game
摘要:Flip GameTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 14735Accepted: 6321DescriptionFlip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the other one is black and each piece is lying either it's bl 阅读全文

posted @ 2011-07-30 01:36 kuangbin 阅读(1718) 评论(0) 推荐(0)

POJ题目分类
摘要:初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. (5)构造法.(poj3295) (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法: (1)图的深度优先遍历和广度优先遍历. (2)最短路径算法(dijkstra,bellman-ford,floyd,heap+dijkstra) (poj1860,poj3259,poj1062,poj2253,poj1125,poj2240) (3)最小生成树算法(prim,krus 阅读全文

posted @ 2011-07-29 10:19 kuangbin 阅读(75413) 评论(17) 推荐(43)

ACM HDU 1020Encoding
摘要:EncodingTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11132Accepted Submission(s): 4673Problem DescriptionGiven a string containing only 'A' - 'Z', we could encode it using the following method: 1. Each sub-string containing k sam 阅读全文

posted @ 2011-07-29 00:53 kuangbin 阅读(1772) 评论(0) 推荐(0)

关于qsort的完整版
摘要:六种qsort排序方法<本文中排序都是采用的从小到大排序>一、对int类型数组排序int num[100];Sample:int cmp ( const void *a , const void *b ){ return *(int *)a - *(int *)b;}qsort(num,100,sizeof(num[0]),cmp);二、对char类型数组排序(同int类型)char word[100];Sample:int cmp( const void *a , const void *b ){ return *(char *)a - *(char *)b;}qsort(wor 阅读全文

posted @ 2011-07-28 21:10 kuangbin 阅读(388) 评论(0) 推荐(0)

ACM HDU 1040 As Easy As A+B
摘要:As Easy As A+BTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 15920Accepted Submission(s): 6448Problem DescriptionThese days, I am thinking about a question, how can I get a problem as easy as A+B? It is fairly difficulty to do such a thing. Of cou 阅读全文

posted @ 2011-07-28 20:37 kuangbin 阅读(1488) 评论(0) 推荐(0)

ACM HDU 1016 Prime Ring Problem
摘要:Prime Ring ProblemTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8651Accepted Submission(s): 3877Problem DescriptionA ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of num 阅读全文

posted @ 2011-07-28 20:20 kuangbin 阅读(696) 评论(0) 推荐(0)

ACM HDU 1017 A Mathematical Curiosity
摘要:A Mathematical CuriosityTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10942Accepted Submission(s): 3371Problem DescriptionGiven two integers n and m, count the number of pairs of integers (a,b) such that 0 < a < b < n and (a^2+b^2 +m)/(a 阅读全文

posted @ 2011-07-28 18:08 kuangbin 阅读(493) 评论(0) 推荐(0)

ACM HDU 3668Volume
摘要:VolumeTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 531Accepted Submission(s): 159Problem DescriptionThis time your job is to calculate the volume of a special object. The object consists of two orthogonal cylinders. The two cylinders intersect e 阅读全文

posted @ 2011-07-28 17:43 kuangbin 阅读(362) 评论(0) 推荐(0)

ACM HDU 3665Seaside
摘要:SeasideTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 396Accepted Submission(s): 272Problem DescriptionXiaoY is living in a big city, there are N towns in it and some towns near the sea. All these towns are numbered from 0 to N-1 and XiaoY lives i 阅读全文

posted @ 2011-07-28 16:35 kuangbin 阅读(356) 评论(0) 推荐(0)

ACM HDU 3664 Permutation Counting
摘要:Permutation CountingTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 493Accepted Submission(s): 258Problem DescriptionGiven a permutation a1, a2, … aN of {1, 2, …, N}, we define its E-value as the amount of elements where ai > i. For example, the 阅读全文

posted @ 2011-07-28 16:09 kuangbin 阅读(1097) 评论(0) 推荐(0)

ACM HDU 3661 Assignments
摘要:AssignmentsTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 645Accepted Submission(s): 300Problem DescriptionIn a factory, there are N workers to finish two types of tasks (A and B). Each type has N tasks. Each task of type A needs xi time to finish 阅读全文

posted @ 2011-07-28 13:22 kuangbin 阅读(725) 评论(0) 推荐(0)

ACM HDU 1019 Least Common Multiple
摘要:Least Common MultipleTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11716Accepted Submission(s): 4278Problem DescriptionThe least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by all the nu 阅读全文

posted @ 2011-07-27 23:47 kuangbin 阅读(4103) 评论(0) 推荐(0)

ACM HDU 1014 Uniform Generator
摘要:Uniform GeneratorTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6215Accepted Submission(s): 2477Problem DescriptionComputer simulations often require random numbers. One way to generate pseudo-random numbers is via a function of the formseed(x+1) 阅读全文

posted @ 2011-07-27 23:23 kuangbin 阅读(1249) 评论(0) 推荐(0)

ACM HDU 1013 Digital Roots
摘要:Digital RootsTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 20786Accepted Submission(s): 6161Problem DescriptionThe digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then tha 阅读全文

posted @ 2011-07-27 18:57 kuangbin 阅读(614) 评论(0) 推荐(0)

ACM HDU 1012
摘要:u Calculate eTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12753Accepted Submission(s): 5485Problem DescriptionA simple mathematical formula for e iswhere n is allowed to go to infinity. This can actually yield very accurate approximations of e u 阅读全文

posted @ 2011-07-27 18:22 kuangbin 阅读(445) 评论(0) 推荐(0)

ACM HDU 1008 Elevator
摘要:ElevatorTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16549Accepted Submission(s): 8795Problem DescriptionThe highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floor 阅读全文

posted @ 2011-07-27 17:57 kuangbin 阅读(2836) 评论(0) 推荐(0)

ACM HDU 1010 Tempter of the Bone
摘要:Tempter of the BoneTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 23769Accepted Submission(s): 6538Problem DescriptionThe doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, a 阅读全文

posted @ 2011-07-27 12:32 kuangbin 阅读(1793) 评论(1) 推荐(2)

最大流问题
摘要:最近又复习了下最大流问题,每次看这部分的内容都会有新的收获。可以说最大流问题的资料网上一搜一大把,根本没有必要自己写;但是大部分资料上的专业术语太多了,初学很难理解,至少我当年学这部分的时候前几次就没有看懂。所以我准备备份一点个人的理解。图-1 如图-1所示,在这个运输网络中,源点S和汇点T分别是1,7,各边的容量为C(u,v)。图中红色虚线所示就是一个可行流。标准图示法如图-2所示:其中p(u,v) / c(u,v)分别表示该边的实际流量与最大容量。 关于最大流 熟悉了什么是网络流,最大流也就很好理解了。就是对于任意的u∈V-{s},使得p(s,u)的和达到最大。上面的运输网络中,最大流如图 阅读全文

posted @ 2011-07-26 20:48 kuangbin 阅读(48953) 评论(5) 推荐(5)

ACM HDU 1005 Number Sequence
摘要:Number SequenceTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 41179Accepted Submission(s): 8827Problem DescriptionA number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.Given A, B, and n, you are to 阅读全文

posted @ 2011-07-26 16:35 kuangbin 阅读(4500) 评论(3) 推荐(0)

ACM HDU 1004 Let the Balloon Rise
摘要:Let the Balloon RiseTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 30662Accepted Submission(s): 10048Problem DescriptionContest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time 阅读全文

posted @ 2011-07-26 15:04 kuangbin 阅读(2606) 评论(2) 推荐(2)

ACM HDU1001Sum Problem
摘要:Sum ProblemTime Limit: 1000/500 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 113869Accepted Submission(s): 26069Problem DescriptionHey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.In 阅读全文

posted @ 2011-07-26 14:28 kuangbin 阅读(284) 评论(0) 推荐(0)

ACM HDU1000A + B Problem
摘要:A + B ProblemTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 150787Accepted Submission(s): 47736Problem DescriptionCalculate A + B.InputEach line will contain two integers A and B. Process to end of file.OutputFor each case, output A + B in one lin 阅读全文

posted @ 2011-07-26 14:27 kuangbin 阅读(300) 评论(0) 推荐(0)

HDOJ题目分类
摘要:模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201 1202 1205 1209 1212(大数取模) 1216(链表)1218 1219 1225 1228 阅读全文

posted @ 2011-07-26 14:05 kuangbin 阅读(13634) 评论(0) 推荐(5)

ACM HDU 1068 Girls and Boys
摘要:Girls and BoysTime Limit: 20000/10000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3019Accepted Submission(s): 1294Problem Descriptionthe second year of the university somebody started a study on the romantic relations between the students. The relation “romantically 阅读全文

posted @ 2011-07-26 13:58 kuangbin 阅读(2086) 评论(0) 推荐(0)

【转】 cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
摘要:学C++的时候,这几个输入函数弄的有点迷糊;这里做个小结,为了自己复习,也希望对后来者能有所帮助,如果有差错的地方还请各位多多指教(本文所有程序均通过VC 6.0运行)转载请保留作者信息;1、cin1、cin.get()2、cin.getline()3、getline()4、gets()5、getchar()1、cin>>用法1:最基本,也是最常用的用法,输入一个数字:#include <iostream>using namespace std;main (){int a,b;cin>>a>>b;cout<<a+b<<en 阅读全文

posted @ 2011-07-26 12:22 kuangbin 阅读(449) 评论(0) 推荐(1)

有向图的强连通分量
摘要:最关键通用部分:强连通分量一定是图的深搜树的一个子树。一、 Kosaraju算法1. 算法思路基本思路:这个算法可以说是最容易理解,最通用的算法,其比较关键的部分是同时应用了原图G和反图GT。(步骤1)先用对原图G进行深搜形成森林(树),(步骤2)然后任选一棵树对其进行深搜(注意这次深搜节点A能往子节点B走的要求是EAB存在于反图GT),能遍历到的顶点就是一个强连通分量。余下部分和原来的森林一起组成一个新的森林,继续步骤2直到 没有顶点为止。改进思路:当然,基本思路实现起来是比较麻烦的(因为步骤2每次对一棵树进行深搜时,可能深搜到其他树上去,这是不允许的,强连通分量只能存在单棵树中(由开篇第一 阅读全文

posted @ 2011-07-25 22:51 kuangbin 阅读(2283) 评论(0) 推荐(1)

ACM HDU 1385Minimum Transport Cost
摘要:Minimum Transport CostTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2369Accepted Submission(s): 584Problem DescriptionThese are N cities in Spring country. Between each pair of cities there may be one transportation track or none. Now there is so 阅读全文

posted @ 2011-07-25 22:26 kuangbin 阅读(550) 评论(0) 推荐(1)

ZOJ Problem Set - 1003Crashing Balloon
摘要:Crashing BalloonTime Limit: 1 Second Memory Limit: 32768 KBOn every June 1st, the Children's Day, there will be a game named "crashing balloon" on TV. The rule is very simple. On the ground there are 100 labeled balloons, with the numbers 1 to 100. After the referee shouts "Let 阅读全文

posted @ 2011-07-25 22:03 kuangbin 阅读(914) 评论(1) 推荐(1)

ACM HDU1465 不容易系列之一
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1465不容易系列之一Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6471Accepted Submission(s): 2684Problem Description大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了!做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的道理一样。话虽这样说,我还是要告 阅读全文

posted @ 2011-07-24 13:12 kuangbin 阅读(914) 评论(0) 推荐(0)

ACM HDU1284 钱币兑换问题
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1284钱币兑换问题Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2064Accepted Submission(s): 1095Problem Description在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法。请你编程序计算出共有多少种兑法。Input每行只有一个正整数N,N小于32768。Output对应每个输入,输出兑换方法数。Sa 阅读全文

posted @ 2011-07-24 13:10 kuangbin 阅读(863) 评论(0) 推荐(2)

ACM HDU2442 ACM(Array Complicated Manipulation)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2441ACM(Array Complicated Manipulation)Time Limit: 5000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 258Accepted Submission(s): 60Problem DescriptionGiven an infinite array of integers 2,3,.... Now do some operations on 阅读全文

posted @ 2011-07-23 23:40 kuangbin 阅读(576) 评论(0) 推荐(1)

ACM HOJ 2087 剪花布条(简单题)
摘要:剪花布条Time Limit: 1000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2814Accepted Submission(s): 1881Problem Description一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢?Input输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少 阅读全文

posted @ 2011-07-23 18:47 kuangbin 阅读(1495) 评论(0) 推荐(1)

int ,long , long long类型的范围
摘要:unsigned int 0~4294967295 int 2147483648~2147483647 unsigned long 0~4294967295long 2147483648~2147483647long long的最大值:9223372036854775807long long的最小值:-9223372036854775808unsigned long long的最大值:18446744073709551615__int64的最大值:9223372036854775807__int64的最小值:-9223372036854775808unsigned __int64的最大值:18 阅读全文

posted @ 2011-07-23 18:10 kuangbin 阅读(176857) 评论(0) 推荐(23)

ACM HOJ 1018 Big Number
摘要:Big NumberTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10639Accepted Submission(s): 4780Problem DescriptionIn many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, 阅读全文

posted @ 2011-07-23 18:06 kuangbin 阅读(1242) 评论(0) 推荐(1)

ACM :HOJ1215 七夕节
摘要:七夕节Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13540Accepted Submission(s): 3831Problem Description七夕节那天,月老来到数字王国,他在城门上贴了一张告示,并且和数字王国的人们说:"你们想知道你们的另一半是谁吗?那就按照告示上的方法去找吧!"人们纷纷来到告示前,都想知道谁才是自己的另一半.告示如下:数字N的因子就是所有比N小又能被N整除的所有正整数,如12的因子有1,2 阅读全文

posted @ 2011-07-23 18:01 kuangbin 阅读(2776) 评论(0) 推荐(0)

乘积最大
摘要:乘积最大问题描述:将一个正整数n分为若干个自然数的和,这些自然数可以相同,(n>1)。你的任务是求整数n的所有这样的和项表示中加数之积的最大值A。但通常由于数很大,直接表示它会有一些困难,为方便起见,我们将A用整数标准分解的方式表示,即A= ,其中诸 是素数,而指数 。于是将A表示成素因数、指数的序列形式 … 输入:输入文件有若干行,每行有一个整数n,1≤n≤50000。输出:对输入中的每个整数n,用一行输出对应的和项表示中加数之积最大值A的标准分解中素因数、指数的序列形式。输入样例:42000输出样例:2 22 1 3 666#include<stdio.h>#includ 阅读全文

posted @ 2011-07-22 21:56 kuangbin 阅读(411) 评论(0) 推荐(0)

盒子放球
摘要:盒子放球问题描述:k个相同的球放入n个不同的盒子。你的任务是计算有多少种不同的放法。输入:输入文件中有若干行。每一行上有两个正整数n和k是一组测试数据,(n³1,k³0)。输入直到文件结束。输出:对输入文件中的每组测试数据,在输出文件输出k个球放入n个不同的盒子放法数。输入样例:3 41 4输出样例151#include<iostream>#include<stdio.h>using namespace std;int com(int n,int r){ int i,j,s=1; if(n-r<r)r=n-r; for(i=0,j=1;i< 阅读全文

posted @ 2011-07-22 21:55 kuangbin 阅读(369) 评论(0) 推荐(0)

升降交替数列
摘要:升降交替数列问题描述有一种长度为n 的特殊数列,具有如下特点:(1)第一项为1;(2)每一项为1、2或3;(3)数列中的项升降交替。例如,长度为3 的特殊数列只有3条:121,132,131。你的任务是计算长度为n 的特殊数列的条数 。输入:输入文件有若干行,每行上有一个整数n,表示特殊数列长度,1≤n≤45。输出:对输入文件中的每个整数n,输出长度为n的特殊数列的条数 。输入样例:37输出样例:321#include<stdio.h>#include<iostream>using namespace std;int f[46];int vext(){ f[1]=1;f 阅读全文

posted @ 2011-07-22 21:54 kuangbin 阅读(481) 评论(0) 推荐(0)

数字和
摘要:数字和问题描述设n是自然数。 是十进制中至多有n个数字的自然数的集合。对于整数k,用 表示 中那些数字之和小于k的元素的集合。有用| |表示 中元素个数。你的任务是对于整数n、k,判断 是否等于2 。输入:输入文件的第一行是一个整数T,1≤T≤20。接下来有T行,每行上有两个整数n,k,之间用一个空格隔开,1≤n, k≤10000。输出:对输入文件中的每对测试数据n,k,输出你的判断结果。如果| |=2| |,那么输出“YES!”,否则输出“NO!”。输入样例:82 36921 95输出样例:NO!YES!#include<stdio.h>#include<iostream& 阅读全文

posted @ 2011-07-22 21:52 kuangbin 阅读(408) 评论(0) 推荐(0)

无连续整数的子集数问题
摘要:问题描述:集合{1、2、3,…,n}无连续整数的子集个数。输入:输入文件中有若干行。每一行上有一个正整数n一组测试数据,(1<£n<45)。输入直到文件结束。输出:对输入文件中的每组测试数据n,在输出文件输出无连续整数的所有子集个数。输入样例:348输出样例5855打表实现 阅读全文

posted @ 2011-07-22 21:51 kuangbin 阅读(569) 评论(0) 推荐(0)

无相邻1问题
摘要:无相邻1问题问题描述:用1、2、3可构作n位数,计算其中没有相邻的1出现的个数。输入:输入文件中有若干行。每一行上有一个正整数n作为一个测试数据,(1<=n<=100)。输入直到文件结束。输出:对输入文件中的每个测试数据,在输出文件输出没有相邻的1出现的n位数的个数。输入样例:341输出样例22603分析:设 f[n]为符合条件的n位数的个数,则 f[n]=2f[n-1]+2f[n-2];#include<stdio.h>#include<iostream>#define MAXN 100using namespace std;char a[100][100 阅读全文

posted @ 2011-07-22 21:43 kuangbin 阅读(541) 评论(0) 推荐(0)

ACM POJ 2245Lotto解题报告
摘要:http://poj.org/problem?id=2245Lotto在玩德国游戏Lotto时,要从集合{1,2,……,49}中取出六个数。一个非常流行的玩法(尽管这种玩法并不能增加你赢的机会)是从这49个数字中取出k个数字(6<k)组成子集S。然后玩游戏的时候仅从S中取出数字。例如,当k=8,S=1,2,3,5,8,13,21,34时,有28种可能的游戏:[1,2,3,5,8,13],[1,2,3,5,8,21],[1,2,3,5,8,34],[1,2,3,5,13,21],……,[3,5,8,13,21,34]。编一个程序,读入k的值和集合S,打印仅从S中取数的所有可能游戏。输入输入 阅读全文

posted @ 2011-07-22 21:31 kuangbin 阅读(971) 评论(0) 推荐(0)

高精度加法的C++实现
摘要:精度计算——加法语法:add(char a[],char b[],char s[]);参数:a[]:被乘数,用字符串表示,位数不限b[]:乘数,用字符串表示,位数不限t[]:结果,用字符串表示返回值:null注意: 空间复杂度为 o(n^2)需要 string.h源程序: void add(char a[],char b[],char back[]){int i,j,k,up,x,y,z,l;char *c;if (strlen(a)>strlen(b)) l=strlen(a)+2; else l=strlen(b)+2;c=(char *) malloc(l*sizeof(char) 阅读全文

posted @ 2011-07-22 14:21 kuangbin 阅读(7136) 评论(2) 推荐(3)

POJ1019:Number Sequence
摘要:http://poj.org/problem?id=1019题目:Number SequenceTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 24168Accepted: 6466DescriptionA single positive integer i is given. Write a program to find the digit located in the position i in the sequence of number groups S1S2...Sk. Each group Sk consists 阅读全文

posted @ 2011-07-21 21:34 kuangbin 阅读(2038) 评论(0) 推荐(0)

导航

JAVASCRIPT: