BZOJ:2018: [Usaco2009] Farm Skills Competition

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.