2011年8月9日
摘要: hdoj1019题目大意:给多个数,求这几个数的最小公倍数解决:递归#include <iostream>using namespace std;int gcd(int a,int b){ if(b==0)return a; else return gcd(b,a%b);}__int64 lcm(int num[],int n){ if(n==1)return num[0]; else { __int64 ret=lcm(num,n-1); return ret* num[n-1] /gcd(ret,num[n-1]); }}int main(){ int icase; cin&g 阅读全文
posted @ 2011-08-09 23:40 猿类的进化史 阅读(342) 评论(0) 推荐(0)
摘要: poj 3984题目大意:解决:bfs,关键是对路径的保存#include <iostream>#include <cstring>#include <vector>#include <queue>using namespace std;int map[5][5];struct node{ int x,y;};//此处定义了一个存放上一个坐标的路径结构体,采用递归输出node path[5][5];queue<node> q;int sx=1,sy=1;int dx[]={1,-1,0,0};int dy[]={0,0,1,-1};i 阅读全文
posted @ 2011-08-09 23:29 猿类的进化史 阅读(312) 评论(0) 推荐(0)
摘要: zoj1711题目大意:给出一个和,求出所给数相加等于这个和的所有不同情况解决:The numbers in each list appear in nonincreasing order, and there may be repetitions.有序是前提,由于有4 6 4 3 2 2 1 1这样的数据存在,我们必须判断重复的等式6=3+2+1(第一个1)或者是6=3+2+1(第二个1)如何判断呢见代码//#include <iostream>#include <cstdio>#include <cstring>using namespace std;i 阅读全文
posted @ 2011-08-09 23:15 猿类的进化史 阅读(205) 评论(0) 推荐(0)
摘要: zoj 1204题目大意:给出一些数字,求出某几个数字之和等于给出的某一个数字 ,并按照要求输出解决: 排序,dfs#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int num[35];bool flag;int res[35],n;void dfs(int start,int dest_deep,int current_deep,int current_sum){ if(current_deep==des 阅读全文
posted @ 2011-08-09 13:04 猿类的进化史 阅读(390) 评论(0) 推荐(0)