Description
Input
Line 1th: 10 spaces separate integers: N, A, B, C, D, E, F, G, H, M
Output
Line 1th: The remainder of the total modulus m of the N-head cows that satisfy the lightest and the highest of the overall weight.
Sample Input2 0 1 5 55555555 0 1 0 55555555 55555555
Sample Output51
HINT
Sample Description: The weight and usefulness of the formula were: Weight: 5, 6, 9, 14, 21, 30 useful degrees: 0, 1, 8, 27, 64, 125.
Violence can be too series
#include <cstdio>#include<algorithm>using namespacestd;structna{Long Longw,u;};Long LongN,a,b,c,d,e,f,g,h,m;na aa[2000001];BOOLcmp (na a,na b) {returna.u>b.u| | a.u==b.u&&a.w<B.W;}intMain () {scanf ("%lld%lld%lld%lld%lld%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d,&e,&f,&g,&h,&l); for(Long LongI=0;i<3*n;i++){ Long Longx= (i*i)%D; AA[I].W= ((a*i%d) * (x*x%d)%d+ (b*x)%d+c)%D; X= (i*i)%I; AA[I].U= ((e*i%h) * (x*x%h)%h+ ((f*x)%h*i)%h+g)%I; } sort (Aa,aa+3*n,cmp); Long Longans=0; for(Long LongI=0; i<n;i++) {ans= (ANS+AA[I].W)%M; } printf ("%lld\n", ans%M);}
BZOJ:2018: [Usaco2009] Farm Skills Competition