摘要:
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=2817快速幂取模问题套用模板就可以View Code 1 #include<stdio.h> 2 #include<string.h> 3 #define M 200907 4 __int64 quickpow(__int64 m,__int64 n) 5 { 6 int b=1; 7 while(n>0) 8 { 9 if(n&1)10 b=(b*m)%M;11 n=n>>1;//位运算 相当于n^212 m=... 阅读全文
posted @ 2012-08-03 19:59
时光旅行的懒猫
阅读(178)
评论(0)
推荐(0)
摘要:
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=2673排序题刚讲了归并排序就用归并排序做View Code 1 #include<stdio.h> 2 void qsort(int a[],int l,int r) 3 { 4 int x=a[l],i=l,j=r; 5 if(l>=r)return; 6 while(i<j) 7 { 8 while(i<=j&&a[j]>=x) 9 j--;10 a[i]=a[j];11 while(i<j&&a[i... 阅读全文
posted @ 2012-08-03 19:48
时光旅行的懒猫
阅读(266)
评论(0)
推荐(0)
摘要:
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1867题目大概意思就是 有重复的就覆盖掉 然后输出。不过这个得比较字符串str1 str2还得再比较str2 str1.思路 KMP算法 掌握的还是不熟。View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #define N 100001 5 int nextt[N]; 6 void next(char s[]) 7 { 8 int i=1,j=0; 9 int len= 阅读全文
posted @ 2012-08-03 18:48
时光旅行的懒猫
阅读(199)
评论(0)
推荐(0)
摘要:
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1753小数的高精度运算思路 把小数点前后分开存,然后统一进位,输出时再输出小数点。View Code 1 #include <stdio.h> 2 #include <string.h> 3 #define N 405 4 int a[N]; 5 int b[N]; 6 int c[N]; 7 int a1[N]; 8 int b1[N]; 9 int c1[N]; 10 int d[N]; 11 char stra[1000]; 12 char strb[1000]; 13 阅读全文
posted @ 2012-08-03 18:44
时光旅行的懒猫
阅读(310)
评论(0)
推荐(0)
摘要:
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1715MS我写的比较麻烦,各种进位什么的,学长说用递归加打表就可以搞定。我的View Code 1 #include<stdio.h> 2 #include<string.h> 3 #define max 1000 4 char n1[max],n2[max],n3[max]; 5 void add(char *n1,char *n2,char *n3) 6 { 7 memset(n3,0,max); 8 int len=strlen(n1); 9 int i;10 ... 阅读全文
posted @ 2012-08-03 18:42
时光旅行的懒猫
阅读(496)
评论(1)
推荐(0)
摘要:
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1106题目难点在分割整数吧,快排可以套用模板。方法1 快排View Code 1 #include<stdio.h> 2 char str[1010]; 3 int a[100000]; 4 void qsort(int a[],int l,int r) 5 { 6 int x=a[l],i=l,j=r; 7 if(l>=r) return; 8 while(i<j) 9 {10 while(i<j&&a[j]>=x)j--;11 a[... 阅读全文
posted @ 2012-08-03 18:39
时光旅行的懒猫
阅读(314)
评论(0)
推荐(0)
摘要:
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1031题意 先按满意度排序,再按序号输出。思路 数据量并不大 用个结构体,用一般的排序就可以。View Code 1 #include<stdio.h> 2 #include<string.h> 3 struct s 4 { 5 int num; 6 double mark; 7 }a[1000],t; 8 int main() 9 {10 int n,m,k,i,j,o,s;11 double d;12 while(~scanf("%d %d %d",&a 阅读全文
posted @ 2012-08-03 18:32
时光旅行的懒猫
阅读(288)
评论(0)
推荐(0)
摘要:
题目链接http://acm.timus.ru/problem.aspx?space=1&num=1100思路 结构体的二级排序 不过要按照先输入先输出的顺序。因此可以先给它赋上编号。然后如果相等的话,按照编号来进行二级排序。先输出编号小的。View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 struct in 4 { 5 int id; 6 int m; 7 int num; 8 }ss[150001]; 9 int cmp(const void *a,const void *b)10 {11 struct 阅读全文
posted @ 2012-08-03 18:18
时光旅行的懒猫
阅读(252)
评论(0)
推荐(0)
摘要:
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1272并查集的简单应用解题思路:题目意思是找到判断是不是连通无环的图,首先想到的就是并查集。 1判断成环的时候,只要判断输入边的两个点。有一个共同的父节点,那么这两个点就成环。 2判断连通的时候,只要判断根节点数为1即可。 注意:当输入的这组数据只有 0 0 时,依然是满足条件的,即应输出 "Yes"。View Code 1 #include<iostream> 2 using namespace std; 3 #define MAX 100005 4 int fath 阅读全文
posted @ 2012-08-03 18:04
时光旅行的懒猫
阅读(396)
评论(0)
推荐(1)
摘要:
这两个是一个类型的题目。放在一块吧。题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1262View Code题目链接http://acm.hdu.edu.cn/showproblem.php?pid=2098View Code 1 #include <stdio.h> 2 #include<math.h> 3 int jud(int n) 4 { int t=sqrt(n),i; 5 t++; 6 for(i=2;i<t;i++) 7 if(n%i==0) return 0; 8 return 1; 9 }10 int 阅读全文
posted @ 2012-08-03 17:57
时光旅行的懒猫
阅读(180)
评论(0)
推荐(0)

浙公网安备 33010602011771号