zoukankan      html  css  js  c++  java
  • bzoj2018 [Usaco2009 Nov]农场技艺大赛

    [Usaco2009 Nov]农场技艺大赛

    Time Limit: 10 Sec  Memory Limit: 162 MB
    Submit: 311  Solved: 153
    [Submit][Status][Discuss]

    Description

    Input

    第1行:10个空格分开的整数: N, a, b, c, d, e, f, g, h, M

    Output

    第1行:满足总重量最轻,且用度之和最大的N头奶牛的总体重模M后的余数。

    Sample Input

    2 0 1 5 55555555 0 1 0 55555555 55555555

    Sample Output

    51

    HINT

    样例说明:公式生成的体重和有用度分别为: 体重:5, 6, 9, 14, 21, 30 有用度:0, 1, 8, 27, 64, 125.

    Source

     
    题解:模拟
     1 #include<cstring>
     2 #include<cmath>
     3 #include<iostream>
     4 #include<algorithm>
     5 #include<cstdio>
     6 #include<cstdlib>
     7 
     8 #define ll long long
     9 using namespace std;
    10 inline int read()
    11 {
    12     int x=0,f=1;char ch=getchar();
    13     while(ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
    14     while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    15     return x*f;
    16 }
    17 ll n,a,b,c,d,e,f,g,h,m;  
    18 struct cow
    19 {  
    20     ll w,u;  
    21 }aaa[1500010];  
    22 inline bool cmp(cow a,cow b)  
    23 {  
    24     return a.u>b.u||a.u==b.u&&a.w<b.w;  
    25 }  
    26 inline void work()  
    27 {  
    28     for(int i=0;i<3*n;i++)  
    29     {  
    30         ll t1=i%d;  
    31         ll t2=(t1*t1)%d;  
    32         ll t5=(((t2*t2)%d)*t1)%d;  
    33         aaa[i].w=(a*t5+b*t2+c)%d;  
    34         ll s1=i%h;  
    35         ll s3=(((s1*s1)%h)*s1)%h;  
    36         ll s5=(((s3*s1)%h)*s1)%h;  
    37         aaa[i].u=(e*s5+f*s3+g)%h;  
    38     }  
    39 }  
    40 int main()  
    41 {  
    42     n=read();  
    43     a=read();  
    44     b=read();  
    45     c=read();  
    46     d=read();  
    47     e=read();  
    48     f=read();  
    49     g=read();  
    50     h=read();  
    51     m=read();  
    52     work();  
    53     sort(aaa,aaa+3*n,cmp);  
    54     ll sum=0;  
    55     for (int i=0;i<n;i++) sum=(sum+aaa[i].w)%m;  
    56     printf("%lld
    ",sum);  
    57 }  
  • 相关阅读:
    http-Content-Type
    ip地址和端口号
    node中的js-核心模块
    http-url 发送请求
    http 发送请求
    node http核心模块
    node 写文件
    bzoj-3170 3170: [Tjoi 2013]松鼠聚会(计算几何)
    codeforces 710E E. Generate a String(dp)
    codeforces 710C C. Magic Odd Square(构造)
  • 原文地址:https://www.cnblogs.com/fengzhiyuan/p/8203962.html
Copyright © 2011-2022 走看看