上一页 1 ··· 3 4 5 6 7 8 9 10 下一页
摘要: 杭电1248题意:用n元买药水,有150,200,350元的,多余的钱当作小费,最少要给多少小费。Analyse:首先,350块的无敌药水可以忽略,因为它可以被一个血瓶和一个魔瓶代替,只要血瓶和魔瓶就可以组合了。然后,假设有50*n+m(0<m<50)块,其最少要给的小费是50*n要给的小费加上m块。以五十块为单位,向前试:大钞面额 0 50 100 150 200 250 300 350 400 450 500 550 600最少小费 0 50 100 0 0 50 0 0 0 0 0 0 0150*4+200*0=60015... 阅读全文
posted @ 2012-07-27 10:02 zlyblog 阅读(164) 评论(0) 推荐(0)
摘要: 杭电1690不理解View Code 1 #include<stdio.h> 2 #include<iostream> 3 using namespace std; 4 #define maxint 0x7f7f7f7f7f7f7f7fLL 5 typedef __int64 LL; 6 LL mat[105][105]; 7 LL cor[105]; 8 LL l1,l2,l3,l4,c1,c2,c3,c4; 9 int n;10 LL change(LL x)11 {12 if(x<0) x=-x;13 if(x>0&&x<=l1) 阅读全文
posted @ 2012-07-26 17:29 zlyblog 阅读(196) 评论(0) 推荐(0)
摘要: 杭电2680Problem DescriptionOne day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s traffic route, and the stations which are near Kiki’s home so that she can take. You may suppos 阅读全文
posted @ 2012-07-26 15:23 zlyblog 阅读(284) 评论(0) 推荐(0)
摘要: 杭电1596其实本题思路还是运用迪杰斯特拉算法,与前面题有所不同的是本题找最大值,这就要注意,在选取过程中,变量的控制;View Code 1 //杭电1596 2 #include<stdio.h> 3 #include<string.h> 4 #define M 999999999 5 #define N 1010 6 int b[N]; 7 double map[N][N],a[N]; 8 int panduan(double x) 9 {10 return x>0?1:0;//实数与零比较11 }12 13 int main()14 {15 int n,m 阅读全文
posted @ 2012-07-26 10:34 zlyblog 阅读(228) 评论(0) 推荐(0)
摘要: 最短路径求解View Code 1 //杭电1874(最短路径) 2 #include<stdio.h> 3 #define Max 10000 4 int n,m,start,end; 5 int a[210],b[210],map[210][210]; 6 void bfs() 7 { 8 int i,j,k,min; 9 for(i=0;i<n;i++)10 a[i]=map[start][i];11 a[start]=0;12 b[start]=1;13 for(i=0;i<n;i++)14 {15 mi... 阅读全文
posted @ 2012-07-25 16:46 zlyblog 阅读(200) 评论(0) 推荐(0)
摘要: 杭电2112View Code 1 //杭电2112 2 #include<stdio.h> 3 #include<string.h> 4 #include<stdlib.h> 5 #define M 99999999 6 #define N 160 7 char s[N][50]; 8 int a[N],b[N],map[N][N]; 9 int n,t,num,k,p,d;10 int MIN(int a,int b)11 {12 return a<b?a:b;13 }14 int look(char a[])15 {16 int i;17 for 阅读全文
posted @ 2012-07-25 16:45 zlyblog 阅读(179) 评论(0) 推荐(0)
摘要: 杭电1160View Code 1 //杭电1160 2 #include<stdio.h> 3 #include<stdlib.h> 4 #define N 1005 5 int b[N],c[N],d[N][N]; 6 struct mouse 7 { 8 int w,v; 9 int id;10 }a[1001];11 int cmp(const void *a,const void *b)12 {13 struct mouse *x,*y;14 x=(struct mouse *)a;15 y=(struct mouse *)b;16 ... 阅读全文
posted @ 2012-07-24 16:00 zlyblog 阅读(198) 评论(0) 推荐(0)
摘要: 杭电1312View Code 1 //1312红与黑 2 #include<stdio.h> 3 #include<string.h> 4 #include<queue> 5 using namespace std; 6 char a[21][21]; 7 int m,n; 8 int sum; 9 int d[4][2]={1,0,-1,0,0,1,0,-1};10 struct node11 {12 int x,y;13 };14 15 int judge(int x,int y)16 {17 if(x>=0&&x<n&am 阅读全文
posted @ 2012-07-20 11:12 zlyblog 阅读(186) 评论(0) 推荐(0)
摘要: View Code 1 //zzuli1220 2 #include<stdio.h> 3 #include<queue> 4 using namespace std; 5 int n,k; 6 int f[100001]; 7 bool a[100001]; 8 queue<int>q; 9 void bfs()10 {11 int x;12 a[n]=1;13 q.push(n);14 while(!q.empty())15 {16 x=q.front();17 q.pop();18 if(x==k)... 阅读全文
posted @ 2012-07-19 17:24 zlyblog 阅读(213) 评论(0) 推荐(0)
摘要: 北大2421题意:输入一个数n,代表村庄数,然后输入n行n列的数组,第i行第j列代表第i个村庄与第j个村庄的距离。然后输入一个数m,接下来m行,每行代表某两个村庄之间的路已被修;输出要修的最短距离,保证每两个村庄之间都可以直接或间接的联系。View Code 1 //2421C++ 2 #include<stdio.h> 3 #include<string.h> 4 #include<stdlib.h> 5 6 #define Max 1005 7 int n,a[Max][Max]; 8 int set[Max],f[Max][Max]; 9 struct 阅读全文
posted @ 2012-07-19 11:40 zlyblog 阅读(248) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 下一页