Last night was the DP engaged in the light, the most gas is to see the puzzle can not understand,
I want to take water today to practice the feel, the results I found that I was wrong,!!! Sum up their mistakes, really want to miss things are not in the wrong, HDU 1070 Milk test instructions: is a person to the supermarket to buy milk, give you some milk brand price capacity, milk shelf life is 6 days, and drink 200ml a day, if a certain milk capacity of less than 200ml this milk directly Was pulled black, and ensure that all the milk is the same day, you want to buy that milk is the cheapest, and he will only buy a bottle of milk, the above given the various brands of milk is a bottle of price capacity, if there are a variety of milk is also cheap, the demand for large output capacity, thinking: not difficult, but test instructions said very wordy, is to ask for the lowest price per liter of milk, but here is a detail, is the capacity of more than 1200ml of milk processing, because he will only drink 1200ml, so even if you have more capacity is redundant, more than the part of the direct
1#include <cstdio>2#include <cstring>3#include <cmath>4 Const intqq= Max;5 structMilk6 {7 Chars[ Max];8 intp;9 intv;Ten }MILK[QQ]; One intPartitionintLintR) A { - inti,j; -Milk x=Milk[l]; thei=l;j=R; - while(1){ - while(I<j && milk[j].v>=x.v)--J; -milk[i]=Milk[j]; + while(I<j && milk[i].v<=x.v) + +i; -milk[j]=Milk[i]; + if(I>=J) Break; A } atmilk[i]=x; - returni; - } - voidQuickintLintR) - { - if(l<S) { in inttemp=partition (l,r); -Quick (l,temp-1); toQuick (temp+1, R); + } - } the intMain () * { $ intT;SCANF ("%d",&t);Panax Notoginseng while(t--){ - intN;SCANF ("%d",&n); the Charstr[ Max]; + intx, y;intCount=0; A for(intI=0; i<n;++i) { thescanf"%s%d%d",str,&x,&y); + if(y< $)Continue; - strcpy (MILK[COUNT].S,STR); $milk[count].p=x; $milk[count++].v=y; - } -Quick0, count-1); Sort it out from the capacity large to the capacity small to compare, theMilk cheap=milk[count-1]; - if(cheap.v>= -)Wuyicheap.v= -; the for(inti=count-2; i>=0;--i) { - if(milk[i].v>= -) Wumilk[i].v= -; - if(cheap.p*1.0/cheap.v* ->milk[i].p*1.0/milk[i].v* -) Aboutcheap=Milk[i]; $ } -printf"%s\n", CHEAP.S); - } - return 0; A}
HDU 1062 Text Reverse test instructions: is to turn all the words to the English composition of the way output this question a bit of a pit, I wrote a few practices WA, but I just do not know where the wrong, first put a right, this practice directly on each word output
1#include <cstdio>2#include <cstring>3#include <stack>4 using namespacestd;5 Chars[ -];6 intblank[1020];7 intMain ()8 {9 intT;SCANF ("%d",&t);Ten GetChar (); One while(t--){ Amemset (Blank,0,sizeof(blank)); - gets (s); - intCount=1; theblank[0]=-1; - intlen=strlen (s); -s[len]=' '; -s[len+1]=' /'; + for(intI=0; I<=strlen (s); + +i) - if(s[i]==' ') +blank[count++]=i; A for(intI=1; i<count;++i) { at for(intj=blank[i]-1; j>=blank[i-1]+1&&s[j]!=' ';--j)//Without s[j]!= ' will WA, I don't know why -printf"%c", S[j]); I think I think it's not a plus. - if(i!=count-1) printf (" "); - } -printf"\ n"); - } in return 0; -}
HDU 1019 Least Common multiple
The problem is really water, a, just pay attention to the data does not overflow on the line, then First Division
Test instructions: The maximum number of common multiple,
Thought: You think if you can find out two of the maximum common multiple, then the maximum common multiple of the number of n is certainly greater than or equal to the maximum common multiple of these two numbers,
1#include <cstdio>2#include <cstring>3#include <cmath>4#include <algorithm>5 using namespacestd;6 Const intqq=50000;7 intgcdintAintb)8 {9 returnb==0? A:GCD (b,a%b);Ten } One intNUM[QQ]; A intMain () - { - intT;SCANF ("%d",&t); the while(t--){ - intN;SCANF ("%d",&n); - for(intI=0; i<n;++i) -scanf"%d",&num[i]); + if(n==1){ -printf"%d\n", num[0]); + Continue; A } at if(num[0]<num[1]){ -num[0]=num[0]+num[1]; -num[1]=num[0]-num[1]; -num[0]=num[0]-num[1]; - } - intmaxn=num[0]/GCD (num[0],num[1]) *num[1]; in for(intI=2; i<n;++i) { - if(NUM[I]>MAXN) Maxn=max (MAXN,MAXN/GCD (NUM[I],MAXN) *num[i]); to ElseMaxn=max (MAXN,MAXN/GCD (maxn,num[i]) *num[i]); + } -printf"%d\n", MAXN); the } *}
Water one wave water problem,