摘要: 1 #include<iostream> 2 using namespace std; 3 const int maxn=10000; 4 int a[maxn]; 5 int n,k; 6 bool prime(int now) 7 { 8 if (now<2) return false; 9 if (now==2) return true;10 for (int i=2;i<now;i++){if (now%i==0) return false;}11 return true;12 }13 void get_input()14 {15 c... 阅读全文
posted @ 2012-07-03 15:42 NoRush 阅读(615) 评论(1) 推荐(1) 编辑
摘要: 1 #include<iostream> 2 using namespace std; 3 char a[100][100]; 4 int x[10000]; 5 int y[10000]; 6 bool vis[100][100]; 7 int n=0,m=0,tot=0,stx,sty; 8 void get_input() 9 {10 cin >> n >> m;11 for (int i=0;i<n;i++)12 for (int j=0;j<m;j++){ 13 cin >> a[i][j];14 vis[i... 阅读全文
posted @ 2012-07-02 22:10 NoRush 阅读(899) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 #include<string> 3 using namespace std; 4 string monkey_name; 5 int a[150]={0}; 6 bool prime(int pre) 7 { 8 if (pre<2) return false; 9 if (pre==2) return true;10 for (int i=2;i<pre;i++) if (pre%i==0) return false;11 return true; 12 }13 int main()14 {1... 阅读全文
posted @ 2012-07-02 19:49 NoRush 阅读(1783) 评论(0) 推荐(0) 编辑
摘要: 为了迎合即将到来的大学专业生活,我开始华丽丽地由Pascal转C++了…写的不好,切忌吐槽 1 #include<iostream> 2 using namespace std; 3 int t,n,ut,ft,dt; 4 const int size = 100000; 5 int a[size]; 6 void get_input() 7 { 8 char tmp; 9 cin >> t >> n >> ut >> ft >> dt; 10 for (int i=0;i<n;i++){11 cin >> 阅读全文
posted @ 2012-07-02 16:34 NoRush 阅读(443) 评论(0) 推荐(0) 编辑
摘要: 二分密度+bellman-ford判断是否存在负权回路。 a,b,e分别代表每条边的起点、终点、权值,mid为当前密度,cost为点的快乐值 在二分密度时,要注意更新边权为e[i]=e[i]*mid-cost[b[i]] [pascal 代码] VAR A,B,COST:ARRAY[1..100000]OF LONGINT; DIS,E,EE:ARRAY[... 阅读全文
posted @ 2011-10-31 11:35 NoRush 阅读(430) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2011-10-31 10:26 NoRush 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 传说中的买一送一……不解释,详情看POJ2110 [pascal 代码] CONST DX:ARRAY[1..4]OF -1..1=(0,0,1,-1); DY:ARRAY[1..4]OF -1..1=(-1,1,0,0);TYPE LZY=RECORD X,Y:LONGINT; END;VAR ... 阅读全文
posted @ 2011-10-29 09:44 NoRush 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 题目大意: 给你一个n×n的矩阵,让你找一条从(1,1)到(n,n)的一条路径,保证路径上经过点的最大值与最小值之差最小,输出这个差值。 题目分析: 典型的二分答案,枚举上下界区间,然后二分差值,求差值的最小值。 [pascal 代码] CONST DX:ARRAY[1..4]OF -1..1=(0,0,1,-1); DY:ARRAY[1..4]OF -1..... 阅读全文
posted @ 2011-10-29 09:37 NoRush 阅读(465) 评论(0) 推荐(2) 编辑
摘要: 上次做到那个收入计划的时候就提到了这道题目,在POJ上是让输出方案,并且保证前面的人赋值的书稿尽量多。所以不需要SJ。 具体实现就是先二分出正确的答案,然后根据答案从后往前进行贪心划分。 [pascal 代码] VAR A,WAY:ARRAY[0..100000]OF LONGINT; N,M,L,R,MID,I,J,TOT,T,IT:LONGINT;FUNCTI... 阅读全文
posted @ 2011-10-29 08:53 NoRush 阅读(331) 评论(0) 推荐(0) 编辑
摘要: 高考结束后,同学们大都找到了一份临时工作,渴望挣得一些零用钱。从今天起,Matrix67将连续工作N天(1<=N<=100 000)。每一天末他可以领取当天及前面若干天里没有领取的工资,但他总共只有M(1<=M<=N)次领取工资的机会。Matrix67已经知道了在接下来的这N天里每一天他可以赚多少钱。为了避免自己滥用零花钱,他希望知道如何安排领取工资的时间才能使得领到工资最多的那一次工资数额最小。... 阅读全文
posted @ 2011-10-28 20:44 NoRush 阅读(748) 评论(0) 推荐(0) 编辑