
ACM
ChallenChenZhiPeng
【人生有很多路要选】选中一条,走下去,便会碰见这条路上的人和风景;而选择另一
条,则是完全不同的风景与人。有的人可能与你一起走,有的人留在原地;一起走的人,也
可能在下个路口与你分开。没什么可哀叹的,这是人生的必然,珍惜身边与你一起看风景的
人,并在下一个分别路口,洒脱地用力地挥挥手。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
统计单词个数并打印
#include#include#include using namespace std;int main(){char string[81];char str[81][20];int i,j=0,num=0,k,word=0;char c;gets(string); for(i=0;(c=string[i])!='\0';i++) { if(c==' ')原创 2012-12-07 09:37:58 · 773 阅读 · 0 评论 -
poj 2709 贪心
import java.util.Arrays;import java.util.Scanner;public class Main2709 { static int Gray=0; public static void main(String[] args) { Scanner in=new Scanner(System.in); while(in.hasNext()){原创 2012-07-09 20:09:10 · 619 阅读 · 0 评论 -
poj 1035 串 枚举 暴力 tmp.insert(i, 1, current[i]); //谁能告诉我这句什么意思?
#include #include #include using namespace std; int ok;int ldic, lstr;string current;vector dic; /* 替换一个字符 */void replace(string dic){ int count = 0; /* 只有一个字符不一样就OK */ for (转载 2012-06-28 22:12:18 · 1192 阅读 · 0 评论 -
POJ 3009 dfs
import java.util.Scanner;public class a3009 { static final int MAX=30; static int w,h,start_x,start_y; static int flag[][]=new int[MAX][MAX]; static int min=11,step=1; static void dfs(int x转载 2012-07-21 17:57:38 · 670 阅读 · 0 评论 -
poj 3278 bfs
import java.io.BufferedInputStream;import java.util.LinkedList;import java.util.Scanner;public class Main3278 { public static final int MAX=2000000; public static void main(String[] args) {原创 2012-07-21 19:55:01 · 528 阅读 · 0 评论 -
poj 1129 四色定理
#include using namespace std; int map[27][27]; int n; int ans[27];//记录每个点的着色的情况 int ok(int s) { for(int i = 0; i < n; i++)//判断是否有相连的并且与该点的颜色相等的 { if(map[i][s]==1 &&原创 2012-07-22 21:17:34 · 974 阅读 · 0 评论 -
poj 3126 bfs
不知道为什么,二种方法一样,第一种就是wrong,第二种就AC了#include #include #include #include using namespace std;int p[9999]={0},visited[9999]={0};bool isprime(int n){ for(int i=2;i<(int)sqrt((double)n);i++){原创 2012-07-22 11:56:58 · 581 阅读 · 0 评论 -
poj 1426
import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.math.BigInteger;public class Main1426 { /** * @param args * @throws IOException * @原创 2012-07-21 20:12:58 · 786 阅读 · 0 评论 -
poj 1113 计算几何 凸包
计算几何相关知识及基本算法 (C语言版) http://blog.youkuaiyun.com/cschf/article/details/2489462#include #include #include #include #include #define N 1000 #define esp 1e-8 #define pi acos(-1.0) using na原创 2012-08-07 19:17:10 · 718 阅读 · 0 评论 -
poj 1664 递归
设f(m,n)为m个苹果,n个盘子的放法数目1:若n>m,必定有n-m个盘子永远空着,去掉它们对摆放苹果方法数目不产生影响,即f(m,n)=f(m,m)2:若n<=m时,不同的放法可以分为两类:即有至少一个盘子空着或者所有盘子都有苹果,前一种情况相当于f(m,n)=f(m,n-1),后一种情况可以从每个盘子中拿走一个苹果,不影响不同放法的数目,即f(m,n)=f(m-n,n),总的放苹果的转载 2012-06-25 19:00:34 · 759 阅读 · 0 评论 -
poj 1936 All in All 水题
#include using namespace std;const int MAX = 100001;int main(){ char s[MAX], t[MAX], *ps, *pt; while (cin >> s >> t){ ps = s; pt = t; while (*pt){ if (*p原创 2012-06-25 18:40:46 · 629 阅读 · 0 评论 -
poj 2305 Java 做,水过了 Basic remains
import java.io.*;import java.util.*;import java.math.*;public class Main { /** * @param args */ public static void main(String[] args) throws IOException { // TODO A原创 2012-06-25 18:31:48 · 635 阅读 · 0 评论 -
poj 1789 Prim最小生成树
#include #include using namespace std;int n,dist[2002][2002];char ch[2002][7];int sum;int distance(char a[],char b[]){ int dc=0; for(int i=0;i<7;i++) {if(a[i]!=b[i]) dc++; }原创 2012-06-22 18:49:47 · 484 阅读 · 0 评论 -
1258 prim
#include #include using namespace std;int n,dist[500][500];int ma;int prime(){ int v,min; int d[500]; int flag[500]; memset(flag,0,sizeof(flag)); for(int i=0;i<n;i++)原创 2012-06-22 19:31:10 · 470 阅读 · 0 评论 -
poj 3436 最大流,需要仔细消化(题意好久都没看懂)
转自:http://hi.baidu.com/you289065406/blog/item/78acc3476f460359500ffe12.html#includeusing namespace std;const int inf=10001;int s; //超级源int t; //超级汇int n; //总结点数(包括超级源、超级汇)int p; //每台机器的部分数转载 2012-06-24 14:25:44 · 681 阅读 · 0 评论 -
poj 3041 二分匹配 基础题(整理版:基础知识)匈牙利算法
通俗易懂的:http://ekumen.iteye.com/blog/265336 模板:http://chhaj5236.blog.163.com/blog/static/1128810812009910102617216/Ford-Fulkerson求解最大流 Edmonds-Karp算法:http://chhaj5236.blog.163.com/blog/static/112881原创 2012-06-24 18:53:07 · 579 阅读 · 0 评论 -
poj 2635 大数模运算(内有打素数表的模板,大树求余分解公式)
题意:求正整数K(4 思路:大数模运算,让比L小的所有素数去除K,如果余数为0则表示存在。先预处理打一张素数表,然后对K按10000进制进行分解,(按1000~1000000000进制都是可行的,其中1000跑了800多MS,100进制就TLE了),然后按照公式(A+B)%C = ((A%C)+(B%C))%C进行模运算。#include #include using name原创 2012-06-25 10:37:29 · 2273 阅读 · 0 评论 -
poj 2603 注意理解题意 数论
数论算法如下:若正整数n可分解为(p1^a1)*(p2^a2)*…*(pk^ak)其中pi为两两不同的素数,ai为对应指数n的约数个数为(1+a1)*(1+a2)*….*(1+ak)。最后,要求的是,约数个数的最后一位#include #include using namespace std;int main(){ int n,a[10001];原创 2012-06-25 11:40:15 · 867 阅读 · 0 评论 -
poj 2488 A Knight's Journey 解题报告 DFS
#include #include const int MAXN=10; int DFS(int tot,int rear,int x,int y); int p,q,way[MAXN*MAXN][2]={0},vis[MAXN][MAXN]; int dx[8]={-2,-2,-1,-1,1,1,2,2}, //按字典序方向行走 dy[8]={-1,1,-2,转载 2012-07-08 16:01:23 · 759 阅读 · 0 评论 -
poj 3096 Surprising Strings
题目大意:给定一个字符串S,从中找出所有有两个字符组成的子串,每当组成子串的字符之间隔着n字符时,如果没有相同的子串出现,则输出 "S is surprising." ,反之,则输出 "S is NOT surprising." 。☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆分割线☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆#include #include using namespace std;s原创 2012-08-19 14:45:05 · 1238 阅读 · 0 评论 -
poj 3252 数论 round numbers
以sample为例子[2,12]区间的RoundNumbers(简称RN)个数:Rn[2,12]=Rn[0,12]-Rn[0,1]即:Rn[start,finish]=Rn[0,finish]-Rn[0,start-1]所以关键是给定一个X,求出Rn[0,X]现在假设X=10100100这个X的二进制总共是8位,任何一个小于8位的二进制都小于X第一部分,求出长度为[0,7]原创 2012-08-18 16:31:13 · 682 阅读 · 0 评论 -
poj 1961 Period (KMP)
#include using namespace std;char a[1000001],nex[1000001];int n;void get_nextval(){ int j=1,k=0; nex[1]=0; while(j<=n) { if(k==0||a[j]==a[k]) {原创 2012-10-03 09:51:51 · 580 阅读 · 0 评论 -
poj 3984 迷宫问题 BFS 图的广度优先搜索
#include using namespace std;int map[5][5];int dx[4]={1,-1,0,0};int dy[4]={0,0,-1,1};int front=0,rear=1;struct node{ int x,y,pre; }q[100];void print(int i){ if(q[i].pre!=-1)原创 2012-10-10 21:52:25 · 989 阅读 · 0 评论 -
poj Kruskal 【poj3723 Conscription : 最大生成树;poj 1251 Jungle Roads: 最小生成树poj1861Network】
poj3723 Conscription : 最大生成树#include #include #define N 20005#define E 50005using namespace std;struct edge{ int u,v,w;}e[E];int n,sum;int father[N],rank[N];bool cmp(edge a,edge b){原创 2012-10-13 16:01:24 · 893 阅读 · 0 评论 -
Prim最小生成树【poj 2349 Arctic Network;poj 1287 NetWorking】
poj 2349 Arctic Network:图我们构造完成,调用prim算法,把该算法中每一次贪心得到的最小权边存入一个数组中。算法结束后对那个数组sort递减排序。这样,前边最大的s个用那卫星让他们通信去。然后从第s开始配给他们足够功率的对讲机使。#include #include #include #include #include #define M原创 2012-10-13 21:09:03 · 720 阅读 · 0 评论 -
poj 1502 MPI Maelstrom
http://blog.youkuaiyun.com/wangjian8006/article/details/*dijstraMemory 160KTime 0MS*/#include #include using namespace std;#define MAXV 102#define INF 100000int map[MAXV][MAXV],n;void dijst转载 2012-10-22 21:03:37 · 672 阅读 · 0 评论 -
poj 3750 小孩报数问题(循环链表)
#include #include using namespace std;struct List{//双向链表结构体 char name[20]; struct List *front; struct List *rear;// 后指针 }; List *create(int n){ List *node,*head; head=node=new List;原创 2012-10-28 18:32:53 · 2341 阅读 · 0 评论 -
大数 除法
#include #include #include #include #include #include #include #define N 10003 using namespace std; void division(char * src,int n) { int len = strlen(src),i,k,t=0,s=0; char dest[原创 2012-12-07 09:22:28 · 753 阅读 · 0 评论 -
动态数组
找出出现奇数次的数字#include #include #include #include #include #include #include using namespace std; struct str { //int d; //输入的数int numb; //以后面相同的次数};int main(){int i,j;int原创 2012-12-07 09:25:14 · 599 阅读 · 0 评论 -
poj 2983 Is the Information Reliable? (Bellman_Ford)
参考:http://blog.youkuaiyun.com/lyy289065406/article/details/6648688#include using namespace std;int n,m;//n太空站树木;m为tip数 const int INF=0x177777;bool sign;int pe;int dist[1001];//源点到各点的距离int w[200原创 2012-09-30 20:28:02 · 666 阅读 · 0 评论 -
二维几何模版
转自:http://bbs.byr.cn/#!article/ACM_ICPC/63442/* Project: AkemiHomura's Standard Code Library [AHSCL] Author: [BUPT]AkemiHomura@PuellaMagi Category: Geometry Title: Geometry B转载 2012-08-26 15:15:00 · 651 阅读 · 0 评论 -
poj 1850 poj 1496
一下分析转自http://blog.youkuaiyun.com/lyy289065406/article/details/6648492分析的很详细,值得好好看!!!POJ1850#include #include using namespace std; int c[27][27]={0}; /*打表,利用转载 2012-08-18 20:09:04 · 656 阅读 · 0 评论 -
poj 1019 Number Sequence
转自:http://user.qzone.qq.com/289065406/blog/1301527312#!app=2&via=QZ.HashRefresh&pos=1301527312#include#includeusing namespace std; const int size=31269; unsigned a[size]; //a[i] 表示转载 2012-08-19 11:39:33 · 624 阅读 · 0 评论 -
poj 1458 Common Subsequence
简单的动态规划#include #include using namespace std;int dp[500][500];string s,t;int max(int a, int b){ return a>=b?a:b;}int lcs(){ int i,j; for(i=1;i<=s.size();i++){ for(j=1;j<=t.size();j++)原创 2012-08-22 19:05:43 · 581 阅读 · 0 评论 -
poj 2533 Longest Ordered Subsequence
#include using namespace std;const int N = 1000;int data[N], dp[N];int main(){int i,j,n,max(1);cin>>n;for(i=0;i<n;i++){ cin>>data[i]; dp[i]=1;}for(i=1;i<n;i++){ for(j=0;j<i;j++){原创 2012-08-22 19:08:20 · 545 阅读 · 0 评论 -
[模板]三维几何模板
转自:http://bbs.byr.cn/#!article/ACM_ICPC/63440/* Project: AkemiHomura's Standard Code Library [AHSCL] Author: [BUPT]AkemiHomura@UESTC_Kyouko Category: Geometry Title: Geometry Bas转载 2012-08-26 19:01:04 · 758 阅读 · 0 评论 -
poj 3393 Lucky and Good Months by Gregorian Calendar 模拟
详细分析见 http://www.cnblogs.com/lyy289065406/archive/2011/07/31/2122851.html #include #include using namespace std;int flagRun=0;int sum;int Month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}原创 2012-08-24 21:01:59 · 790 阅读 · 0 评论 -
sort()函数与qsort()函数
sort()函数是C++中的排序函数其头文件为:#include头文件;qsort()是C中的排序函数,其头文件为:#include1、qsort()----六类qsort排序方法qsort函数很好用,但有时不太会用比如按结构体一级排序、二级排序、字符串排序等。函数原型:void qsort(void *base, size_t nelem, size_t widt转载 2012-08-25 10:25:41 · 809 阅读 · 0 评论 -
poj 1716 贪心 Integer Intervals
大致题意:给出数轴上的n个区间,每个区间都是连续的int区间。现在要在数轴上任意取一堆元素,构成一个元素集合V要求每个区间和元素集合V的交集至少有两个不同的元素求集合V最小的元素个数。解题思路:贪心算法先对所有区间按末端点排序取第i个区间的最后两个元素temp和p若第i+1个区间包含了这两个元素,则跳到下一个区间所取的原创 2012-08-25 13:39:37 · 815 阅读 · 0 评论 -
poj 2578 水题 Keep on Truckin'
题目其实是要我们读入三个数,然后判断是否比小于168,如果小于168,就输出第一个小于168的否则输出‘NO CRASH’#include using namespace std;int main(){ int arr[3]; int NotSafe; int i; while(cin>>arr[0]>>arr[1]>>arr[2]) { NotSafe=0;原创 2012-06-25 18:20:56 · 921 阅读 · 0 评论