03 2012 档案
摘要: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...
阅读全文
摘要: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
阅读全文
摘要: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 ...
阅读全文
摘要:http://ac.jobdu.com/problem.php?id=1325 并查集View Code 1 #include<iostream> 2 using namespace std; 3 struct node 4 { 5 int x,y; 6 }; 7 node edge[1000008];//edge 8 int father[1008]; 9 int n,m,k;10 void initSet()11 {12 for(int i=0;i<=n;i++) father[i]=i;13 }14 int find(int x)15 {16 int i=x,temp.
阅读全文
摘要:http://ac.jobdu.com/problem.php?id=1016大数相加原理View Code 1 /*大数相加原理*/ 2 #include<iostream> 3 #include<vector> 4 #include<cmath> 5 #include<cstring> 6 #include<algorithm> 7 #include<cstdlib> 8 using namespace std; 9 vector<int>prime; 10 vector<int>v1;// 1
阅读全文
摘要: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...
阅读全文
摘要:http://ac.jobdu.com/problem.php?id=1398 注意可能有多个最大最小值,找出最左的最小值和最右的最大值即可,用cout超时View Code 1 #include<iostream> 2 #include<climits> 3 #include<cstdio> 4 using namespace std; 5 int a[208]; 6 int main() 7 { 8 int n; 9 while(scanf("%d",&n)==1)10 {11 int i;12 for(i=0;i<n;
阅读全文
摘要: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
阅读全文
摘要:View Code 1 1001 这个就不用说了吧 2 1002 简单的大数 3 1003 DP经典问题,最大连续子段和 4 1004 简单题 5 1005 找规律(循环点) 6 1006 感觉有点BT的题,我到现在还没过 7 1007 经典问题,最近点对问题,用分治 8 1008 简单题 9 1009 贪心 10 1010 搜索题,剪枝很关键 11 1011 12 1012 简单题 13 1013 简单题(有个小陷阱) 14 1014 简单题 15 1015 可以看作搜索题吧 16 1016 经典的搜索 17 1017 简单数学题 18 1018 简单数学题 19 10...
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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(
阅读全文
摘要: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(
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1075字典树View Code 1 /*字典树,翻译*/ 2 #include<iostream> 3 #include<cstring> 4 #include<cstdlib> 5 using namespace std; 6 struct node 7 { 8 node* child[26]; 9 char word[12];10 };11 node*root=new node();12 void init()//初始化 13 {14 for(int i=0;i<
阅读全文
摘要:http://ac.jobdu.com/problem.php?id=1399View Code 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #include<cmath> 5 using namespace std; 6 struct node 7 { 8 int w,v;//这里改成double 会超时 9 };10 node item[100008];11 bool cmp(const node &a,const node &b)12 {13
阅读全文
摘要:http://ac.jobdu.com/problem.php?id=1420View Code 1 #include<iostream> 2 #include<cstring> 3 #include<cmath> 4 #include<cstdlib> 5 using namespace std; 6 int main() 7 { 8 int n; 9 while(cin>>n)10 {11 int *a=new int[n];12 int i,j,sum=0;13 for(i=0;i<n;i++) cin>>a[
阅读全文
摘要:http://ac.jobdu.com/problem.php?id=1335View Code 1 /*宽度搜索,注意对于宽度搜索树中 ,第几层的记录, 2 层数即是最短步数*/ 3 #include<iostream> 4 #include<cstdio> 5 #include<queue> 6 using namespace std; 7 class node 8 { 9 public: node(int x1,int y1,int deep1)10 {11 x=x1;12 y=y1;13 deep=deep1;14 }15 ...
阅读全文
摘要:http://ac.jobdu.com/problem.php?id=1402 用map超时了View Code 1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include<bitset> 5 #include<climits> 6 using namespace std; 7 int main() 8 { 9 bitset<1000008>b1,b2;//放到main外面,编译通不过? 10 int n,x,i;11 while(scanf
阅读全文
摘要:http://ac.jobdu.com/problem.php?id=1346View Code 1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cmath> 5 using namespace std; 6 typedef struct node 7 { 8 int id,score; 9 };10 node a[1008];11 int n,m;12 bool cmp(const node &a,const node &b)13
阅读全文
摘要:http://ac.jobdu.com/problem.php?id=1380View Code 1 /*每个正数都是一个32位二进制串,只有一个lucky number 2 lucky出现m%n次,其他为n次,如果没有lucky,序列中个位为0的整数和 3 都是n的整数倍,lucky出现m%n次,统计序列中1的整数的个数,假设为C 4 若C%n==0 luck的个位为0,否则C%n一定为m%n,且luck个位为1 5 其它位跟给位一样*/ 6 #include<iostream> 7 #include<cstring> 8 #include<cstdio>
阅读全文

浙公网安备 33010602011771号