這道題用到了最短路和dp的知識,感覺是一道不錯的題目首先根據原題所提供的圖,已2為起點求一次單源最短路徑,然後再根據題目所說的,當d[i]>d[j]時則可以從i到j,所以可以按照這個要求建另外一個圖,這個圖就是很典型的一個“數塔”模型了,所以再dp一下,就可以求出路線數。具體看代碼實現。#include<iostream>#include<cstdio>#include<vector>using namespace std;const int
Little penguin Polo likes permutations. But most of all he likes permutations of integers from0 ton, inclusive.For permutation p = p0, p1, ..., pn, Polo has defined its beauty — number .Expression means applying the operation of bitwise excluding
這是一道比較經典的二分匹配,將格子按黑白標記後,再將含'*'的格子按黑白分成兩組,建邊。最後的結果就是總的'*'的個數-匹配數。#include<iostream>#include<cstdio>#include<vector>using namespace std;vector<int>map[400];//按奇偶性建二分圖 int t,n,m;int match[400],fy[400],ln,rn; int map1[41][11];
這題同hdu3746一樣,都是通過KMP找到字串的最小迴圈節。這題wa了一次,剛開始以為一定有len%(len-next[len-1])==0,後來證實是錯的。如:ababa,按照之前的做法輸出2,很顯然n=1。#include<stdio.h>#include<string.h>#define N 1000005char s[N];int next[N],len;void getnext(){ int i,j; next[0]=0; for(i=
CoinsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4196 Accepted Submission(s): 1669Problem DescriptionWhuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One day
Holedox MovingTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 12148 Accepted: 2905DescriptionDuring winter, the most hungry and severe time, Holedox sleeps in its lair. When spring comes, Holedox wakes up, moves to the exit of its lair,
Treasure of the Chimp IslandTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 231 Accepted Submission(s): 108Problem DescriptionBob Bennett, the young adventurer, has found the map to the