08 2013 档案
HDU1244Max Sum Plus Plus Plus
摘要:Max Sum Plus Plus PlusTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1042Accepted Submission(s): 524 Problem Description给定一个由n个正整数组成的整数序列a1 a2 a3 ... an求按先后次序在其中取m段长度分别为l1、l2、l3...lm的不交叠的连续整数的和的最大值。Input第一行是一个整数n(0 ≤ n ≤ 1000),n = 0表示输入结束 第二行的第一.
阅读全文
HDU4497GCD and LCM
摘要:GCD and LCMTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 50Accepted Submission(s): 27Problem DescriptionGiven two positive integers G and L, could you tell me how many solutions of (x, y, z) there are, satisfying that gcd(x, y, z) = G and lcm(x,
阅读全文
最长递增子序列
摘要:转自http://qiemengdao.iteye.com/blog/1660229问题给定一个长度为N的数组,找出一个最长的单调自增子序列(不一定连续,但是顺序不能乱)。例如:给定一个长度为6的数组A{5, 6, 7, 1, 2, 8},则其最长的单调递增子序列为{5,6,7,8},长度为4.解法1:最长公共子序列法这个问题可以转换为最长公共子序列问题。如例子中的数组A{5,6, 7, 1, 2, 8},则我们排序该数组得到数组A‘{1, 2, 5, 6, 7, 8},然后找出数组A和A’的最长公共子序列即可。显然这里最长公共子序列为{5, 6, 7, 8},也就是原数组A最长递增子序列。最
阅读全文
求回文子串个数(待补充)
摘要:#include#include#includeusing namespace std;#define MAXN 5005char str[MAXN];int main(){// freopen("C:\\Users\\Sky\\Desktop\\1.in","r",stdin);//PLEASE DELETE IT!!!!!!!!!!!!!!!!!!!!!!!! while(~scanf("%s",&str)) { int len=strlen(str),l,r; int ans=len; for(int i=0; i=0&
阅读全文
HDU4686矩阵快速幂
摘要:Arc of DreamTime Limit: 2000/2000 MS (Java/Others)Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 297Accepted Submission(s): 93Problem DescriptionAn Arc of Dream is a curve defined by following function:wherea0 = A0ai = ai-1*AX+AYb0 = B0bi = bi-1*BX+BYWhat is the value of AoD(N) modulo
阅读全文
HDU1274展开字符串(递归)
摘要:#include #include #include #include using namespace std;string s;int fun(int ith,int num){// printf("",num); int k,e; char c; for(c=s[ith++]; ith>T; while(T--) { s.clear(); cin>>s; fun(0,0);//进入递归 cout<<endl; } return 0;}View Code 展开字符串Time Limit: ...
阅读全文
取模问题
摘要:很多地方用到模运算,这里说明模运算的一些规律,并加以证明。 后续会对这些理论实际的应用加以记录和说明。1. 模运算是取余运算(记做 % 或者 mod),具有周期性的特点。 m%n的意思是n除m后的余数,当m递增时m%n呈现周期性特点,并且n越大,周期越长,周期等于n。 例如 0 % 20 = 0,1 % 20 = 1, 2 % 20 = 2, 3 % 20 = 3, ..., 19 % 20 =19 20 % 20 = 0,21 % 20 = 1,22 % 20 = 2,23 % 20 = 3, ...,39 % 20 =192. 如果 m % n = r,那么可以推出如下等式 m =...
阅读全文
ACM南京邀请赛Yet another end of the world数学题
摘要:Yet another end of the worldTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 0Accepted Submission(s): 0 Problem DescriptionIn the year 3013, it has been 1000 years since the previous predicted rapture. However, the Maya will not play a joke any mor
阅读全文
用c语言实现作曲与播放教程~,原创哦~
摘要:本程序可以通过输入简谱用windows自带蜂鸣器函数播放出音乐,会编程的你可以借此在朋友面前show一下啦,哈哈首先,下面这个是样例程序,里面有《国歌》《樱花草》《菊花台》《朋友》《生日快乐》这几首歌曲,以后有时间再做一些播放直接引用相应函数即可 1 #include 2 #include 3 void check(); 4 void Birthday(); 5 void JuHuaTai(); 6 void YingHuaCao(); 7 void GuoGe(); 8 void PengYou(); 9 int main() 10 { 11 PengYou(); ...
阅读全文
实现彩色文字
摘要:1 #include 2 #include 3 //GetStdHandle和SetConsoleTextAttribute在头文件windows.h中 4 #include 5 using namespace std; 6 void SetColor(unsigned short ForeColor=3,unsigned short BackGroundColor=0) 7 //给参数默认值,使它 8 //可以接受0/1/2个参数 9 { 10 HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); //本例以输出为例 11 SetC...
阅读全文
贪吃蛇
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #define MAX__X 23 7 #define MAX__Y 50 8 #define MAX_FOOD 50 9 #define ESC 27 10 #define SPACE 32 11 12 typedef struct Node 13 { 14 int x; 15 int y; 16 struct Node *next; 17 } Node,*LinkList; 18 19 typedef struct 20...
阅读全文
分数类
摘要:1 #include 2 #include 3 using namespace std; 4 class Fract 5 { 6 public: 7 Fract(){num=0;den=1;} 8 Fract(int a=0,int b) 9 { 10 if(b==0) 11 { 12 cout>(istream &in,Fract &a);//重载>> 49 friend Fract operator * (const Fract &a,int i);//分数乘整数 50 ...
阅读全文
胡搞之读心术
摘要:#include#includevoid main(){ float a,e,check1; int b,c,d; char w; printf("=====================读心术======================\n\n"); printf("请按照以下要求计算,你将会看到这个神奇的数字:1089\n"); printf("请输入一个三位数,百位和十位不要相同:\n"); scanf("%f",&a); b=a/100; c=a/10-b*10; d=a-c*10-b*100;
阅读全文
HDU1258Sum It Up
摘要:Sum It UpTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3129Accepted Submission(s): 1578 Problem DescriptionGiven a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if t
阅读全文
HDU1016数字排列搜索
摘要:Prime Ring ProblemTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 20363Accepted Submission(s): 9115 Problem 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
阅读全文
HDU4608 Magic Pen 6
摘要:Magic Pen 6Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 840Accepted Submission(s): 304 Problem DescriptionIn HIT, many people have a magic pen. Lilu0355 has a magic pen, darkgt has a magic pen, discover has a magic pen. Recently, Timer also got
阅读全文
二叉搜索树
摘要:对应HDU3791#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std ;#ifdef DeBUG#define bug assert#else#define bug //#endif#define zero {0}#define INF 2000000000#define eps 1e-6typedef struct _Node //二叉树类,n保存变量{ int n;...
阅读全文