上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 25 下一页

2011年7月25日

HDU 1022 stack 的应用

摘要: #include <iostream>#include<stack>#include<stdio.h>#include<string.h>#include<stdlib.h>#include<string>using namespace std;int N;string come;string leave;int order[50];int main(){ setbuf(stdout,NULL); stack<char>s; while(cin>>N) { cin>>come; cin& 阅读全文

posted @ 2011-07-25 22:04 lonelycatcher 阅读(232) 评论(0) 推荐(0) 编辑

HDU 1019 LCM 求最小公倍数

摘要: #include<stdio.h>#include<cstdlib>#include <iostream>using namespace std;int GCD(int x,int y){ if(!x || !y)return x>y?x:y; for(int t;t=x%y;x=y,y=t); return y;}int LCM(int x,int y){ int gcd=GCD(x,y); return x/gcd*y;}int ans;int main(){ setbuf(stdout,NULL); int T,number,i,inter; s 阅读全文

posted @ 2011-07-25 10:54 lonelycatcher 阅读(241) 评论(0) 推荐(0) 编辑

HDU 1016 Prime Ring Problem 搜索题

摘要: #include<stdio.h>#include<string.h>#include <iostream>using namespace std;int N;int prime[12]={2,3,5,7,11,13,17,19,23,29,31,37};int ring[25];int visited[25];int search(int low ,int high,int x){ if(low>high)return 0; int mid=(low+high)>>1; if(x==prime[mid])return mid; else 阅读全文

posted @ 2011-07-25 09:59 lonelycatcher 阅读(257) 评论(0) 推荐(0) 编辑

HDU 1018 Big number 斯特林公式,lnN!=NlnN-N+0.5*ln(2*N*pi)

摘要: 这道数学题用到了数论中的一个公式,叫做斯特林公式,lnN!=NlnN-N+0.5*ln(2*N*pi)//============================================================================// Name : HDU.cpp// Author : lonelycatcher// Version :// Copyright : Your copyright notice// Description : Hello World in C++, Ansi-style//================================ 阅读全文

posted @ 2011-07-25 09:56 lonelycatcher 阅读(1397) 评论(0) 推荐(0) 编辑

2011年7月23日

POJ 1195 mobile phones 二维树状数组

摘要: 题意很简单,就是求一定范围内子矩阵的和,数据量很大,用暴力的话一定会超时,这道题用二维的树状数组做比较简单。。。#include<stdio.h>#include<string.h>#include <iostream>using namespace std;#define MAX 1030int tree[MAX][MAX];int S,ans;int lowbit(int x){return x&(-x);}void add(int x,int y,int num){ for(int i=x;i<=S;i+=lowbit(i)) { for 阅读全文

posted @ 2011-07-23 13:09 lonelycatcher 阅读(199) 评论(0) 推荐(0) 编辑

上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 25 下一页

导航