Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <iomanip>
- #include <algorithm>
- typedef unsigned int uint;
- uint const G=4;
- uint const L=5;
- uint const N=G*L;
- struct player
- {
- char const *name=0;
- char race=0;
- uint points=0;
- };
- player const P[L][G]=
- {
- {
- {"Maru",'T',3185},
- {"Rogue",'Z',2937},
- {"Trap",'P',2897},
- {"Serral",'Z',2670}
- },
- {
- {"Clem",'T',2536},
- {"Dark",'Z',2397},
- {"Cure",'T',2153},
- {"Zest",'P',1976}
- },
- {
- {"Reynor",'Z',1914},
- {"Heromarine",'T',1573},
- {"Solar",'Z',1369},
- {"Time",'T',1333}
- },
- {
- {"Scarlett",'Z',1315},
- {"Neeb",'P',1265},
- {"Bunny",'T',1240},
- {"Special",'T',1237}
- },
- {
- {"Dream",'T',1172},
- {"Zoun",'P',1106},
- {"Showtime",'P',752},
- {"Lambo",'Z',740}
- }
- };
- uint sum_P=0;
- uint perm[L][G]=
- {
- {0,1,2,3},
- {0,1,2,3},
- {0,1,2,3},
- {0,1,2,3},
- {0,1,2,3}
- };
- uint sgp[L][G]={};
- uint n=0,nl=0;
- uint const M=11000;
- uint nmp[M]={};
- uint nmg[G]={};
- uint nmgt=0;
- double const D=297.0;
- double limit_D=0.0;
- uint const limit=10056; // d~297.1
- int min_sd2=0;
- void rec(uint l)
- {
- if(l<L)
- {
- do
- {
- for(uint i=0; i<G; ++i)
- sgp[l][i]=sgp[l-1][i]+P[l][perm[l][i]].points;
- rec(l+1);
- }
- while(std::next_permutation(perm[l],perm[l]+G));
- }
- else
- {
- uint mp=sgp[L-1][0];
- uint mg=0;
- bool mgt=0;
- for(uint i=1; i<G; ++i)
- {
- if(mp<sgp[L-1][i])
- {
- mp=sgp[L-1][i];
- mg=i;
- mgt=0;
- }
- else if(mp==sgp[L-1][i])
- {
- mgt=1;
- }
- }
- ++nmp[mp];
- if(limit<=mp)
- {
- ++nmg[mg];
- nmgt+=mgt;
- ++nl;
- }
- bool has_min_sd2=0;
- {
- int sd2=0;
- for(uint i=0; i<G; ++i)
- {
- int d=int(sum_P)-int(G*sgp[L-1][i]);
- int d2=d*d;
- sd2+=d2;
- }
- if(sd2==min_sd2)
- std::cout << "dup" << std::endl;
- if(n==0 || sd2<min_sd2)
- {
- min_sd2=sd2;
- has_min_sd2=1;
- }
- }
- if(has_min_sd2)
- {
- std::cout << double(min_sd2)/G/G << std::endl;
- for(uint j=0; j<G; ++j)
- {
- std::cout
- //<< "ABCDEF"[j] << " "
- << sgp[L-1][j] << " ";
- for(uint i=0; i<L; ++i)
- {
- uint k=perm[i][j];
- std::cout
- << P[i][k].name << ","
- << P[i][k].race << ","
- << P[i][k].points
- << " ";
- }
- std::cout << std::endl;
- }
- }
- ++n;
- }
- }
- int main()
- {
- for(uint l=0; l<L; ++l)
- for(uint i=0; i<G; ++i)
- sum_P+=P[l][i].points;
- limit_D=double(D*L*(G-1)+sum_P)/G;
- for(uint i=0; i<G; ++i)
- sgp[0][i]=P[0][i].points;
- rec(1);
- std::cout << "n=" << n << " sum_P=" << sum_P << " limit_D=" << limit_D << std::endl;
- std::cout << "nmg=(";
- for(uint i=0; i<G; ++i)
- std::cout << (i?",":"") << nmg[i];
- std::cout << "), nmgt=" << nmgt << " nl=" << nl << std::endl;
- for(uint m=0,sn=0; m<M; ++m)
- if(nmp[m])
- {
- double avg_mg=double(m)/L;
- double avg_og=double(sum_P-m)/((G-1)*L);
- double d=avg_mg-avg_og;
- if(limit-100<m)
- {
- std::cout << m << " " << nmp[m] << " " << sn
- << std::fixed << std::setprecision(2)
- << " " << avg_og << " " << avg_mg << " d=" << d
- << std::fixed << std::setprecision(6)
- << " " << double(n-sn)/n
- << std::endl;
- }
- sn+=nmp[m];
- //std::cout << m << "," << nmp[m] << std::endl;
- //std::cout << m << "," << sn << std::endl;
- }
- return 0;
- }
- /*
- min variation of sum group points
- 8951 Maru,T,3185 Zest,P,1976 Solar,Z,1369 Scarlett,Z,1315 Zoun,P,1106
- 8924 Rogue,Z,2937 Dark,Z,2397 Heromarine,T,1573 Neeb,P,1265 Showtime,P,752
- 8944 Trap,P,2897 Cure,T,2153 Reynor,Z,1914 Bunny,T,1240 Lambo,Z,740
- 8948 Serral,Z,2670 Clem,T,2536 Time,T,1333 Special,T,1237 Dream,T,1172
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement