随笔分类 -  hdu

摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1108View Code 1 #include<iostream> 2 #include<cmath> 3 using namespace std; 4 int gcd(int a1,int b1)// 5 { 6 int a=max(a1,b1); 7 int b=min(a1,b1); 8 int temp=a%b; 9 while(temp!=0)10 {11 a=b;12 b=temp;13 temp=a%b;14 ... 阅读全文
posted @ 2012-04-03 17:01 keepmoving89 阅读(138) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1106 简单View Code 1 #include<iostream> 2 #include<cstring> 3 #include<vector> 4 #include<cstdlib> 5 #include<algorithm> 6 using namespace std; 7 vector<int>v; 8 void fun(string s)//分离数值到向量 9 {10 v.clear();11 int i,len=s.len 阅读全文
posted @ 2012-04-03 16:52 keepmoving89 阅读(123) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1076View Code 1 #include<iostream> 2 using namespace std; 3 bool isleap(int year) 4 { 5 if(year%4==0 && year%100!=0) return true; 6 if(year%400==0) return true; 7 return false; 8 } 9 int main()10 {11 int t,year,num;12 cin>>t;13 while(t-.. 阅读全文
posted @ 2012-04-02 20:38 keepmoving89 阅读(140) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1060 m=n^n;两边同取对数,log10(m)=n*log10(n); m=10^(n*log10(n))=(10^n)*(10^(n*log10(n))然后,对于10的整数次幂,第一位是1,所以,左边第一位数取决于n*log10(n)的小数部分View Code 1 #include<iostream> 2 #include<cmath> 3 using namespace std; 4 int main() 5 { 6 int n,t; 7 cin>>t; 8 wh 阅读全文
posted @ 2012-04-02 19:14 keepmoving89 阅读(134) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1059 多重背包View Code 1 #include<iostream> 2 #include<cstring> 3 #include<cmath> 4 using namespace std; 5 int dp[120008]; 6 int num[7],total=0;// 7 bool dp1()//能装一半,返回true 8 { 9 memset(dp,0,sizeof(dp));10 int half=total/2;11 //cout<<&quo 阅读全文
posted @ 2012-04-02 17:34 keepmoving89 阅读(269) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1056简单 模拟View Code 1 #include<iostream> 2 #include<cmath> 3 #include<cstring> 4 using namespace std; 5 int main() 6 { 7 double len; 8 while(cin>>len && len) 9 {10 double sum=1.0/2.0;11 if(sum>=len) {cout<<"1 card 阅读全文
posted @ 2012-04-02 12:47 keepmoving89 阅读(156) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1051 先对length排序,再找出weight的递增序列(不一定连续) 个数View Code 1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 struct node 6 { 7 int x,y; 8 }; 9 node a[5008];10 bool flag[5008];11 int n;12 bool cmp(const node & 阅读全文
posted @ 2012-04-02 11:07 keepmoving89 阅读(238) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1049 模拟题View Code 1 #include<iostream> 2 #include<vector> 3 #include<cstring> 4 #include<cstdlib> 5 using namespace std; 6 int main() 7 { 8 int n,u,d; 9 while(cin>>n>>u>>d)10 {11 if(n==0 && u==0 && d= 阅读全文
posted @ 2012-04-02 09:57 keepmoving89 阅读(144) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1047 大数相加,没ACView Code 1 #include<iostream> 2 #include<vector> 3 #include<cstring> 4 #include<cstdlib> 5 using namespace std; 6 void add(string a,string b,string &sum) 7 { 8 sum=""; 9 int alen=a.length(),blen=b.length(); 阅读全文
posted @ 2012-04-02 09:20 keepmoving89 阅读(152) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1045 暴力搜索View Code 1 #include<iostream> 2 #include<cstring> 3 #include<cstdlib> 4 #include<cstdio> 5 using namespace std; 6 char mat[10][10]; 7 int n,maxx; 8 bool ok(int x,int y)//put here is ok 9 {10 if(mat[x][y]!='.') return 阅读全文
posted @ 2012-04-01 23:24 keepmoving89 阅读(124) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1114背包View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 using namespace std; 6 #define INF 99999999 7 struct node 8 { 9 int w;10 int v;11 };12 node a[508];13 int dp[10008];14 int n,sum;15 void s 阅读全文
posted @ 2012-04-01 12:44 keepmoving89 阅读(122) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1040简单排序View Code 1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 const int N=1008; 5 int a[N]; 6 int main() 7 { 8 int t; 9 cin>>t;10 while(t--)11 {12 int n,i;13 cin>>n;14 for(i=0;i<n;i++) cin>>a[i];1... 阅读全文
posted @ 2012-03-31 21:22 keepmoving89 阅读(181) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1035 模拟View Code 1 #include<iostream> 2 #include<cstring> 3 #include<cstdlib> 4 using namespace std; 5 const int N=200; 6 char mat[N][N]; 7 int step[N][N];//到达改点的步数 8 int n,m,s; 9 void initMat()10 {11 for(int i=0;i<N;i++)12 for(int j=0;j 阅读全文
posted @ 2012-03-31 17:08 keepmoving89 阅读(151) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1034 模拟题View Code 1 #include<iostream> 2 using namespace std; 3 int a[100000]; 4 int b[100000];//a的一半 5 int n; 6 int main() 7 { 8 while(cin>>n && n) 9 {10 int i;11 for(i=0;i<n;i++) cin>>a[i];12 int num=0;13 ... 阅读全文
posted @ 2012-03-30 23:14 keepmoving89 阅读(196) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1032 简单模拟View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<iostream> 4 using namespace std; 5 int getnum(long long n) 6 { 7 int num=1; 8 while(n!=1) 9 {10 if(n&1) n=3*n+1;11 else n/=2;12 num++;13 }14 retur... 阅读全文
posted @ 2012-03-30 10:21 keepmoving89 阅读(143) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1085 母函数View Code 1 /*母函数*/ 2 #include<iostream> 3 #include<cstring> 4 using namespace std; 5 const int N=20000; 6 int c1[N],c2[N];//c[i]是x的i次方的系数 7 int num1,num2,num3; 8 void multiply() 9 {10 memset(c2,0,sizeof(c2));11 memset(c1,0,sizeof(c1));12 阅读全文
posted @ 2012-03-29 22:34 keepmoving89 阅读(134) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1162 最小生成树prim算法View Code 1 //*最小生成树,prim算法*/ 2 #include<iostream> 3 #include<cstring> 4 #include<cmath> 5 #include<cfloat>//DBL_MAX 6 #include<iomanip> 7 using namespace std; 8 struct node 9 {10 double x,y;11 };12 node point[10 阅读全文
posted @ 2012-03-29 21:10 keepmoving89 阅读(164) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1142 Dijkstra求最短路径,记录最短路径的条数,cnt记录最短路径的条数出错,不知道错在哪里?View Code 1 #include<iostream> 2 #include<cstring> 3 #include<climits> 4 #include<cmath> 5 using namespace std; 6 #define M 2000000 7 int mat[1008][1008]; 8 bool visited[1008]; 9 int 阅读全文
posted @ 2012-03-29 20:30 keepmoving89 阅读(172) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1213 并查集View Code 1 #include<iostream> 2 #include<algorithm> 3 #include<climits> 4 #include<cstdio> 5 using namespace std; 6 int father[1008]; 7 int t,n,m; 8 void init(int n) 9 {10 for(int i=0;i<=n;i++) father[i]=i;11 }12 int find( 阅读全文
posted @ 2012-03-29 11:20 keepmoving89 阅读(175) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1075 map实现View Code 1 /*map实现,翻译*/ 2 #include<iostream> 3 #include<cstring> 4 #include<cstdlib> 5 #include<map> 6 using namespace std; 7 map<string,string>mat; 8 void print(string s)//找出s对应的英语单词 9 {10 if(mat[s].length()) printf( 阅读全文
posted @ 2012-03-29 09:58 keepmoving89 阅读(153) 评论(0) 推荐(0)