摘要: Number SequenceProblem 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 calculate the value of f(n).InputThe input consists of multiple test cases. Each test case contains 3 integers A, B and n on a single 阅读全文
posted @ 2011-04-13 20:50 cpoint 阅读(382) 评论(0) 推荐(0) 编辑
摘要: Let the Balloon RiseProblem DescriptionContest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and find the result.This ye 阅读全文
posted @ 2011-04-13 20:45 cpoint 阅读(688) 评论(0) 推荐(0) 编辑
摘要: Max SumProblem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14.InputThe first line of the input contains an integer T(1<=T<=20) which means the 阅读全文
posted @ 2011-04-13 20:32 cpoint 阅读(406) 评论(0) 推荐(1) 编辑
摘要: A + B Problem IIProblem DescriptionI have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.InputThe first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two p 阅读全文
posted @ 2011-04-13 19:32 cpoint 阅读(556) 评论(0) 推荐(0) 编辑
摘要: 基础题: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、1109、1157、1163、1164、1170、1194、1196、1197、1201、1202、1205、1219、1234、1235、1236、1248、1266、1279、1282、1283、1302、1303、1323、1326、1330、1 阅读全文
posted @ 2011-04-13 19:22 cpoint 阅读(5482) 评论(0) 推荐(0) 编辑
摘要: 1、功能:产生0到1之间均匀分布的一个随机数2、方法说明:设m=216,产生产生0到1之间均匀分布的一个随机数的计算公式如下:ri=mod(2053ri-1 +13849,m),i=1,2,3……pi =ri/m例:连续产生10个0到1之间均匀分布的一个随机数。r的初值取5.0Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1#include"stdio.h"2doublernd1(double*r)3{intm;4dou 阅读全文
posted @ 2010-12-16 23:32 cpoint 阅读(7103) 评论(0) 推荐(1) 编辑
摘要: #include<stdio.h>#include<math.h>#define N 10void quicksort(int a[],int low,int high);int split(int a[],int low,int high);main(){ int a[N],i; printf("Enter %d numbers to be sorted: ",N); for(i=0;i<N;i++) { scanf("%d",&a[i]); } quicksort(a,0,N-1); printf("I 阅读全文
posted @ 2010-12-08 15:34 cpoint 阅读(265) 评论(0) 推荐(1) 编辑
摘要: 循环不变式(loop invariant)主要来帮助我们来理解算法的正确性。对于循环不变式,必需证明它的三个性质:初始化:它在循环的第一轮迭代开始之前,应该是正确的。保持:如果在循环的某一次迭代开始之前它是正确的,那么,在下一次迭代开始之前,它也应该保持正确。终止:当循环结束时,不变式给了我们一个有用的性质,它有助于表明算法是正确的。关循环不变式与数学归纳法有些类似,但是与它的常见用法不同:在归纳法中,归纳的步骤是无穷地使用的;而在这儿,当循环结束时, 即终止“归纳”。霍纳规则的正确性:以下代码片段实现了用于计算多项式的霍纳规则Code highlighting produced by Act 阅读全文
posted @ 2010-09-13 18:55 cpoint 阅读(967) 评论(3) 推荐(2) 编辑
摘要: 一个是关于去除一个数组中的重复数问题:如定义一个int型数组:{1,1,3,5,6,3,6,9};要求写一个函数得到如下数据{1,3,5,6,9},即重复出现的数只保存第一次出现的那一个数据。源代码如下:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-... 阅读全文
posted @ 2010-09-09 01:15 cpoint 阅读(16322) 评论(0) 推荐(1) 编辑
摘要: 问题提出:设x,y为非负整数,试计算集合M={2^x*3^y|x>=0,y>=0}的元素小于指定整数n的个数,并求这些元素从小到大排序的第m项。以下给出案例求解的三种设计:1.穷举求解设计要点:集合元素由2的幂与3的幂及其乘积组成,设元素从小到大排序的第k项为f(k)。显然,f(1)=1,f(2)=2。设置a从3开始递增至n循环,对每一个a(赋值给j),逐次试用2试商,然后逐次试用3试... 阅读全文
posted @ 2010-09-09 01:02 cpoint 阅读(1417) 评论(0) 推荐(1) 编辑
浏览次数:travelocity promotion codes