A Walk Through the Forest http://acm.hdu.edu.cn/showproblem.php?pid=1142 "He considers taking a path from A to B to be progress if there exists a route from B to his home that is shorter than any possible route from A." 閲嶅湪鐞嗚В榪欏彞璇濄傚厛姹傚嚭鎵鏈夐《鐐瑰埌欏剁偣2鐨勬渶鐭礬(浠ラ《鐐?涓烘簮鐐瑰仛涓嬈ijkstra)錛岀劧鍚庝粠欏剁偣1寮濮嬭蹇嗗寲鎼滅儲銆?br>If (d[u] > d[v]) Sum += bfs(v);
Minimum Transport Cost http://acm.hdu.edu.cn/showproblem.php?pid=1385 Floyd璺緞杈撳嚭錛岄鐩鎸夎礬寰勭殑瀛楀吀搴忚緭鍑猴紱 if (p[i][k] + p[k][j] == map[i][j] && path[i][k] < path[i][j]) path[i][j] = path[i][k]; 鍗沖彲
Arbitrage http://acm.hdu.edu.cn/showproblem.php?pid=1217 闂鏄槸鍚﹀彲浠ョ泩鍒╋紝濡傛灉鎴戜滑鎶婃眹鐜囩湅鎴愯竟錛屽綋涓涓偣閫氳繃鏌愪簺璺緞榪斿洖鍒拌嚜宸卞悗鐨勫煎ぇ浜?錛屽垯鐩堝埄錛?br> A strange lift http://acm.hdu.edu.cn/showproblem.php?pid=1548 鍥犱負杈圭殑鏉冨奸兘涓?錛孊FS錛孌ijkstra閮藉彲浠?br>
]]>鐭╅樀鐨勫揩閫熸瘮杈?HDU2807 The Shortest Pathhttp://www.shnenglu.com/doer-xee/archive/2009/12/04/102503.html瑗塊钀х憻瑗塊钀х憻Fri, 04 Dec 2009 01:05:00 GMThttp://www.shnenglu.com/doer-xee/archive/2009/12/04/102503.htmlhttp://www.shnenglu.com/doer-xee/comments/102503.htmlhttp://www.shnenglu.com/doer-xee/archive/2009/12/04/102503.html#Feedback12http://www.shnenglu.com/doer-xee/comments/commentRss/102503.htmlhttp://www.shnenglu.com/doer-xee/services/trackbacks/102503.htmlhttp://acm.hdu.edu.cn/showproblem.php?pid=2807
#include <iostream> usingnamespace std; #define N 81 #define INF 99999999 int map[N][N], n, m; struct node{ int Map[N][N]; } rec[N];
struct nnode{ int Map[N]; }recone[N];
void cmp(int a, int x) { int i; for (i=1; i<=m; i++) if (recone[x].Map[i] != recone[0].Map[i]) return; map[a][x] =1; }
void creat(int a, int b) { int i, j, k, s; for (i=1; i<=m; i++) { recone[0].Map[i] =0; for (j=1; j<=m; j++) { recone[0].Map[i] += rec[a].Map[i][j] * recone[b].Map[j]; } }
for (i=1; i<=n; i++) if (i != a && i != b) cmp(a, i); //鍒ゆ柇 a 涓?nbsp;i鐨勫叧緋?/span> }
int main() { int i, j, k; while (scanf("%d %d", &n, &m), n+m) { for (i=1; i<=n; i++) for (map[i][i]=0, j=i+1; j<=n; j++) map[i][j] = map[j][i] = INF; //鍒濆鍖栫煩闃典箣闂村叧緋?/span> for (k=1; k<=n; k++) { for (i=1; i<=m; i++) { recone[k].Map[i] =0; for (j=1; j<=m; j++) { scanf("%d", &rec[k].Map[i][j]); recone[k].Map[i] += rec[k].Map[i][j] * j; // 2->1 } } } // 鎺ュ彈鐭╅樀淇℃伅 for (i=1; i<=n; i++) for (j=1; j<=n; j++) if (i != j) creat(i, j); // 澶勭悊鐭╅樀 i*j for (k=1; k<=n; k++) for (i=1; i<=n; i++) for (j=1; j<=n; j++) if (map[i][k] + map[k][j] < map[i][j]) map[i][j] = map[i][k] +map[k][j]; scanf("%d", &m); while (m--) { scanf("%d %d", &i, &j); if (map[i][j] != INF) printf("%d\n", map[i][j]); else printf("Sorry\n"); } } return0; }
]]>HDU 1787 GCD Again 錛堟鎷夊嚱鏁幫級http://www.shnenglu.com/doer-xee/archive/2009/12/02/102408.html瑗塊钀х憻瑗塊钀х憻Wed, 02 Dec 2009 12:34:00 GMThttp://www.shnenglu.com/doer-xee/archive/2009/12/02/102408.htmlhttp://www.shnenglu.com/doer-xee/comments/102408.htmlhttp://www.shnenglu.com/doer-xee/archive/2009/12/02/102408.html#Feedback0http://www.shnenglu.com/doer-xee/comments/commentRss/102408.htmlhttp://www.shnenglu.com/doer-xee/services/trackbacks/102408.htmlhttp://acm.hdu.edu.cn/showproblem.php?pid=1787
/*** count the number of the integers M (0<M<N) which satisfies gcd(N,M)>1. 鍗籌細N - 1 - phi(N)
]]>hdu2824 The Euler function 嬈ф媺鍑芥暟http://www.shnenglu.com/doer-xee/archive/2009/12/01/102353.html瑗塊钀х憻瑗塊钀х憻Tue, 01 Dec 2009 11:21:00 GMThttp://www.shnenglu.com/doer-xee/archive/2009/12/01/102353.htmlhttp://www.shnenglu.com/doer-xee/comments/102353.htmlhttp://www.shnenglu.com/doer-xee/archive/2009/12/01/102353.html#Feedback1http://www.shnenglu.com/doer-xee/comments/commentRss/102353.htmlhttp://www.shnenglu.com/doer-xee/services/trackbacks/102353.html
]]>hdu3215 The first place of 2^n錛堝鏁版濇兂錛?/title>http://www.shnenglu.com/doer-xee/archive/2009/11/27/102056.html瑗塊钀х憻瑗塊钀х憻Fri, 27 Nov 2009 06:25:00 GMThttp://www.shnenglu.com/doer-xee/archive/2009/11/27/102056.htmlhttp://www.shnenglu.com/doer-xee/comments/102056.htmlhttp://www.shnenglu.com/doer-xee/archive/2009/11/27/102056.html#Feedback1http://www.shnenglu.com/doer-xee/comments/commentRss/102056.htmlhttp://www.shnenglu.com/doer-xee/services/trackbacks/102056.htmlhttp://acm.hdu.edu.cn/showproblem.php?pid=3215 棰樼洰澶ф剰鏄綆?^0鍒?^n涓瘡涓暟鐨勬渶宸﹁竟涓浣嶏紝鐒跺悗璁板綍1-9姣忎釜鏁板瓧鍑虹幇鐨勬鏁板茍渚濇鎵撳嵃鍑烘潵錛?br>鑰冭檻鍒皀鐨勮寖鍥?[0,10000]錛?涓嶅彲鑳藉幓璁$畻 2^n
]]>HDU2809 God of War(鍔ㄦ佽鍒掍箣鐘舵佸帇緙╋級http://www.shnenglu.com/doer-xee/archive/2009/11/26/102003.html瑗塊钀х憻瑗塊钀х憻Thu, 26 Nov 2009 12:46:00 GMThttp://www.shnenglu.com/doer-xee/archive/2009/11/26/102003.htmlhttp://www.shnenglu.com/doer-xee/comments/102003.htmlhttp://www.shnenglu.com/doer-xee/archive/2009/11/26/102003.html#Feedback0http://www.shnenglu.com/doer-xee/comments/commentRss/102003.htmlhttp://www.shnenglu.com/doer-xee/services/trackbacks/102003.htmlhttp://acm.hdu.edu.cn/showproblem.php?pid=2809 HH澶х墰鍑虹殑棰樼洰錛屾瘮璧涚殑鏃跺欒鍞綇浜嗘病鏈夊幓鍋氾紝浠婂ぉ鍏磋嚧鏉ヤ簡璁ょ湡鏁蹭簡涓涓嬶紝縐掓潃 榪欓璺?074doing homework涓鏍鳳紝浣嶅帇緙╋紝娌$殑璇達紝鑷簳鍚戜笂璁$畻錛岃鍥?br>
#include<iostream> usingnamespace std; #define N 1100000 int m,n,hp,ati,def; struct node{ int ati; int def; int hp; int lv; int exp; }q[N],tt; struct man{ int ati; int def; int hp; int exp; }man[21]; int max(int a,int b) { return a>b?a:b; } int war(int j,int i) { int time; time=man[i].hp/max(1,q[j].ati-man[i].def); if(man[i].hp%max(1,q[j].ati-man[i].def)==0) time--; if(time>=0) return time; return-1; } void dp() { int i,j,time,add,temp,next; for(j=0;j<m;j++) { if(q[j].hp<=0) continue; for(i=0;i<n;i++) { temp=j>>i; if(temp&1) continue; else next=j+(1<<i); if((time=war(j,i))==-1) continue;//鎴樻枟澶辮觸錛宑ontinue tt=q[j]; tt.hp-=time*max(1,man[i].ati-tt.def); tt.exp+=man[i].exp; if(tt.exp>=100) { add=tt.exp/100; tt.exp%=100; tt.ati+=add*ati; tt.def+=add*def; tt.hp+=add*hp; tt.lv+=add; } if(q[next].hp==0||tt.hp>q[next].hp||(q[next].hp==tt.hp&&(tt.lv*100+tt.exp)>(q[next].lv*100+q[next].exp))) { q[next]=tt; } } q[j].hp=0; } } int main() { int i; char name[22]; while(scanf("%d%d%d%d%d%d",&q[0].ati,&q[0].def,&q[0].hp,&ati,&def,&hp)>0) { scanf("%d",&n); for(i=0;i<n;i++) scanf("%s%d%d%d%d",name,&man[i].ati,&man[i].def,&man[i].hp,&man[i].exp); m=(1<<n)-1; q[0].lv=1; q[0].exp=0; for(i=1;i<=m;i++) { q[i].hp=0; } dp(); if(q[m].hp>0) printf("%d\n",q[m].hp); else printf("Poor LvBu,his period was gone.\n"); } return0; }