Title Description
Coincides with the national Day of H, the King invited the N ministers to play a prize-winning game. First, he let each minister in the left and right
Write an integer on each hand, and the king himself writes an integer on the left and right. Then, let the N-ministers rank
In a row, the king stood at the front of the procession. When the team is lined up, all the ministers will receive some gold coins for the King's reward, each
The number of gold coins received by the Minister is: the product of the number of the left hand of all the people in front of the minister divided by his own right
The number on the hand, and then the result is rounded down.
The king does not want a particular minister to receive a special reward, so he would like to ask you to help him reschedule the order of the team,
So that the most rewarding ministers receive as little reward as possible. Note that the king's position is always at the front of the team.
Input/output format
Input Format:
The first line contains an integer n, representing the number of ministers.
The second line contains two integers a and b, separated by a space, representing the whole number of the king's left and right hand.
Next n rows, each line contains two integers a and b, separated by a space, each of which represents the left hand of each minister
And an integer on the right hand.
output Format:
The output has only one row, which contains an integer representing the number of the most awarded ministers in the rearranged ranks.
Number of coins.
Input/Output sample
Input Sample # #:
Sample # # of output:
2
Description
"Input and Output sample description"
According to the ranks of Ministers 1, 2 and 3rd, the number of gold coins received by the ministers who received the most prizes was 2;
According to the ranks of 1, 3 and 2, the number of gold coins received by the most rewarding ministers was 2;
According to the ranks of 2, 1 and 3, the number of gold coins received by the most rewarding ministers was 2;
According to the ranks of 2, 3 and 1, the number of gold coins received by the most rewarding ministers was 9;
According to the ranks of 3, 1 and 2, the number of gold coins received by the most rewarding ministers was 2;
According to the ranks of 3, 2 and 1, the number of gold coins received by the most rewarding ministers was 9.
As a result, the most rewarding minister receives at least 2 gold coins, and the answer output is 2.
"Data Range"
For 20% of the data, there are 1≤n≤10,0 < A, b < 8;
For 40% of the data, there are 1≤n≤20,0 < A, b < 8;
For 60% of the data, there are 1≤n≤100;
For 60% of the data, the answer is not more than 109;
For 100% of data, there are 1≤n≤1,000,0 < A, b < 10000.
NOIP 2012 Raising the first day of the group the second question
Through the sense of blind to make a lot of complex proofs and derivation, the product of the right hand of each person to the standard, from small to large sort, and then from left to right to multiply, in which position can get the maximum value.
Need to use high precision.
↑ High Precision is disgusting, it has been tuned for a long time.
1 /*by Silvern*/2#include <iostream>3#include <algorithm>4#include <cstring>5#include <cstdio>6#include <cmath>7 using namespacestd;8 intRead () {9 intx=0, f=1;CharCh=GetChar ();Ten while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} One while(ch>='0'&& ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} A returnx*F; - } - structhn{ the inta[2400]; - intLen; - }num,c,ans; - BOOLCMP (HN a,hn b) { + if(A.len<b.len)return 1; - for(inti=a.len;i;--i) { + if(A.a[i]<b.a[i])return 1; A if(A.a[i]>b.a[i])return 0; at } - return 0; - } - voidN_mul (intx) { -HN t;t.len=num.len+Ten; -memset (T.A,0,sizeoft.a); in for(intI=1; i<=num.len;i++){ -t.a[i]+=num.a[i]*x; tot.a[i+1]=t.a[i]/10000; +t.a[i]%=10000; - } the //num.len+=10; * while(t.a[t.len]==0&& t.len>1) t.len--; $num=T;Panax Notoginseng return; - } the voidN_div (intx) { +memset (C.A,0,sizeofC.A); A inttmp=0; thec.len=0; + for(inti=num.len;i;i--){ -tmp=10000*tmp+Num.a[i]; $ if(tmp>=x) { $ if(!c.len) c.len=i; -c.a[i]=tmp/x; -tmp%=x; the } - }Wuyi return; the } - voidPRI (HN num) { Wuprintf"%d", Num.a[num.len]); - for(inti=num.len-1;i>0;--i) { Aboutprintf"%d", num.a[i]/ +); $printf"%d", num.a[i]/ -%Ten); -printf"%d", num.a[i]/Ten%Ten); -printf"%d", num.a[i]%Ten); - } Aprintf"\ n"); + return; the } - // $ structnode{ the intb; the intC; the}m[ -]; the voidQsortintLintR) { - if(l<R) { in intI=l,j=r; Node x=M[l]; the while(i<j) { the while(I<j && m[j].c>=x.c) j--; Aboutm[i]=M[j]; the while(I<j && m[i].c<=x.c) i++; them[j]=M[i]; the } +m[i]=x; -Qsort (l,i-1); theQsort (i+1, R);Bayi } the return; the } - intN; - intMain () { then=read (); thescanf"%d", &num.a[1]); thescanf"%d",&Num.len); thenum.len=1; - inti,j; the for(i=1; i<=n;i++){ theM[i].a=read (); them[i].b=read ();94m[i].c=m[i].a*m[i].b; the } theQsort1, n); the //for (i=1;i<=n;i++) printf ("%d", m[i].c);p rintf ("\ n");98 //for (i=1;i<=n;i++) printf ("re:%d%d\n", m[i].a,m[i].b); Aboutans.len=1; -ans.a[1]=0;101 for(i=1; i<=n;i++){102 N_div (m[i].b);103 //PRI (c);104 if(CMP (ANS,C)) ans=C; the //PRI (ans);106 //printf ("num:"); PRI (num); 107 N_mul (M[I].A);108 }109 PRI (ans); the return 0;111}
[NOIP2012] Improved group Rokua P1080 King Game