【文章內容簡介】
i=0。 i=n。 i++)pre[i]=1,inque[i]=0,base[i]=i。 ()。 (S)。 inque[S]=1。 while(!()) { int u=()。 ()。 for(int v=1。 v=n。 v++) { if(g[u][v]amp。amp。base[v]!=base[u]amp。amp。match[u]!=v) { if(v==S||(match[v]!=1amp。amp。pre[match[v]]!=1))contract(u,v,n)。 else if(pre[v]==1) { pre[v]=u。 if(match[v]!=1)(match[v]),inque[match[v]]=1。 else { u=v。 while(u!=1) { v=pre[u]。 int w=match[v]。 match[u]=v。 match[v]=u。 u=w。 } return true。 } } } } } return false。}int solve(int n){ SET(match,1)。 int ans=0。 for(int i=1。 i=n。 i++) if(match[i]==1amp。amp。dfs(i,n)) ans++。 return ans。}int main(){ int ans。 int n,m。 char tmp[30]。 scanf(%d,amp。n)。 while(n) { ans=0。 memset(g,0,sizeof(g))。 scanf(%d,amp。m)。 for(int i=1。i=m。i++) { scanf(%s,tmp+1)。 for(int j=1。j=m。j++) { if(tmp[j]==39。Y39。) { g[i][j]=g[j][i]=1。 } } } ans=solve(m)。 printf(%d\n,ans*2)。 } return 0。}2010機試ECNU的含義Wele to 2009 ACM selective trial Description Wele to 2009 ACM selective trial. ACM is a long way to go, and it39。s not just a match. So what you need to do for now is do your best! And as members of ACM lab, we are going to teach you something important. Firstly you should be proud that you are a member of ECNU, because 39。E39。 represents Excellent, 39。C39。 represents Cheer, 39。N39。 represents Nice, 39。U39。 represents Ultimate. Second you should remember Impossible is nothing, because Impossible represents I39。m possible. Third for today you should keep ACM, because for you ACM represents Accept More.Do you remember them clearly?Now we will give you a string either E ,C, N,U,Impossible orACM, you need to tell me what does it means? Input The first line of input gives the number of cases, N(1 ≤ N ≤ 10). N test cases follow.Each test consists of a string which will be one of E ,C, N,U,Impossible orACM. Output Tell me what does it means.Sample Input 3EImpossibleACM Sample Output ExcellentI39。m possibleAccept More includeincludechar str[20]。int main(){int N。scanf(%d,amp。N)。while(N){scanf(%s,str)。if(strcmp(str,E)==0)printf(Excellent\n)。else if(strcmp(str,C)==0)printf(Cheer\n)。else if(strcmp(str,N)==0)printf(Nice\n)。else if(strcmp(str,U)==0)printf(Ultimate\n)。else if(strcmp(str,Impossible)==0)printf(I39。m possible\n)。else if(strcmp(str,ACM)==0)printf(Accept More\n)。}return 0。}空瓶換啤酒Soda Surpler Description Tim is an absolutely obsessive soda drinker,he simply cannot get enough. Most annoyinglythough, he almost never has any money, so his only obvious legal way to obtain more soda is to take the money he gets when he recycles empty soda bottles to buy new ones. In addition to the empty bottles resulting from his own consumption he sometimes find empty bottles in the street. One day he was extra thirsty, so he actually drank sodas until he couldn39。t aford a new one. Input Three nonnegative integers e,f, c, where e 1000 equals the number of empty sodabottles in Tim39。s possession at the start of the day, f 1000 the number of empty sodabottles found during the day, and 1 c 2000 the number of empty bottles required tobuy a new soda. Output How many sodas did Tim drink on his extra thirsty day? Sample Input 9 0 3 5 5 2 Sample Output 49 includeincludeint main(){ int e,f,c。 int t。 int sum。 int full,empty。 while(scanf(%d%d%d,amp。e,amp。f,amp。c)!=EOF) { sum=0。 empty=e+f。//空瓶數(shù)量 while(empty=c)//空瓶數(shù)量可換 { sum+=empty/c。//換的滿瓶 empty=empty/c+empty%c。//新的空瓶數(shù)量 } printf(%d\n,sum)。 }return 0。}統(tǒng)計字符統(tǒng)計字符 Description 輸入一行字符,分別統(tǒng)計其中 英文字母、空格、數(shù)字和其他字符的個數(shù)。 Input 輸入一個整數(shù)t,表示有幾組數(shù)據(jù)接下來有t行,每行字符不超過10000個Hint 可能有空格之類的字符 Output 對于每行字符輸出其中1英文字母(大小寫都算)的個數(shù) 2數(shù)字的個數(shù)3其他字符的個數(shù) Sample Input 2q2 e2qweqrwwerr232424fwetetg===2342gdsg3.,/=@321Sample Output character:2number:2others:1character:21number:14others:9 includeincludechar str[10010]。int main(){int t。int i。int ,nn,on。scanf(%d,amp。t)。getchar()。//清除上一個換行符while(t){gets(str)。int l=strlen(str)。=nn=on=0。for(i=0。il。i++){if(str[i]=39。039。amp。amp。str[i]=39。939。)nn++。else if(str[i]=39。A39。amp。amp。str[i]=39。Z39。||str[i]=39。a39。amp。amp。str[i]=39。z39。)++。elseon++。}printf(character:%d\n,)。printf(number:%d\n,nn)。printf(others:%d\n,on)。}return 0。}2010機試熱身粽子買三送一,買五送二端午節(jié)快樂 Description 今天是端午節(jié),ECNU決定請大家吃粽子。恰好,今天超市為了迎合端午節(jié),推出了端午大酬賓,即促銷活動。嚴格的買三送一,買五送二。ECNU想用現(xiàn)有的錢,買最多的粽子,但是他自己又不會算,所以希望你能幫幫他。 Input 輸入第一行為一個數(shù)N(1=N=100),表示測試數(shù)據(jù)的組數(shù)。每組測試數(shù)據(jù)有兩個整數(shù),A,B (0=A=1000,0B10)表示ECNU有A元錢,每個粽子價格為B元錢,超市推出了買5個送2個,和買3個送1個的活動。 Output 輸出ECNU最多能買到的粽子數(shù)量。 Sample Input 210 322 3Sample Output 49Hint:有兩組測試數(shù)據(jù):對于第一組測試數(shù)據(jù):有10元錢,粽子3元一個,可以買3個,但是買3送1,所以最后有4個。對于第二組測試數(shù)據(jù):有22元錢,粽子3元一個,可以買7個,但是買5送2,所以最后有9個。 includeincludeint main(){ int n。 int a,b。 int zn。 int num。 scanf(%d,amp。n)。 while(n) { scanf(%d%d,amp。a,amp。b)。//輸入錢數(shù)和粽子單價 zn=a/b。//買了zn個num=zn。 if(zn/5!=0) { num+=zn/5*2。 zn=zn%5。 } if(zn/3!=0) { num+=zn/3。 }printf(%d\n,