zoukankan      html  css  js  c++  java
  • K:Guanguan's Happy water (The Preliminary Contest for ICPC Asia Shenyang 2019)

    Rather than drinking happy water, Guanguan loves storing happy water. So he bought a refrigerator and stored a_iai bottles of cola into it every day. When the storage is finished on the kk-th day, the refrigerator is full, but he still wants to store happy water every day. Here comes the solution: He first constructs a p-sequence: p_1p1p_2p2, ..., p_kpk, where p_1+p_2+...+p_k=1p1+p2+...+pk=1. Then he chooses an number ii among 11 to kk, where number ii has the probability p_ipi to be chosen. After that, he drinks the happy water stored on the ii-th day before the current day and stores the same amount of happy water back into the refrigerator again. Let the amount of happy water stored on the ii-th day be f_ifi. Given the amount of happy water stored in the first kk days and the expected amount of the next kk days(which means, from the k+1k+1-th day to the 2k2k-th day), could you help Guanguan figure out the sum of the expected amount of happy water stored during the first nn days) (Be aware that every element of ff has moded 1e9+71e9+7 when input datas, and your output should mod 1e9+71e9+7 as well)

    Input

    The first line is TT (1 le T le 201T20), indicating the number of input sets. For each set of inputs, the first line is kk and nn (1 le k le 701k70, 1 le n le 10^{18}1n1018), and the second line is 2k2k numbers, respectively representing a_1a1a_2a2, ..., a_kakf_{k+1}fk+1f_{k+2}fk+2, ..., f_{2k}f2k.

    Output

    For each data, output a non-negative integer indicating (sum_{i=1}^n f_i) mod 10^9+7(i=1nfi)mod109+7.

    样例输入

    2
    1 9
    2 2
    2 8
    6 5 5 5
    

    样例输出

    18
    41

    分析:强调((((m-n)%1000000007)*k)%1000000007),一定一定一定((m-n)%1000000007) 不然你会WA到自闭!!!
    
    


    int main()
    {
        lli t,n,m,k,cnt; //long long <=> lli
        for(cin>>t;t;t--)
        {
            lli sum=0;
            cin>>n>>m;
            for(lli i=1;i<=n;i++)
            {
                cin>>k;
                sum=k%1000000007 + sum%1000000007;
            }
            cin>>k;
            for(lli i=2;i<=n;i++)
                cin>>cnt;
            cout<<(sum%1000000007+ ((((m-n)%1000000007)*k)%1000000007)  )%1000000007<<endl;
        }
        ok;
    }
    所遇皆星河
  • 相关阅读:
    docker 部署aps.net MVC到windows容器
    docker 搭建私有仓库 harbor
    解决关于:Oracle数据库 插入数据中文乱码 显示问号???
    ionic cordova build android error: commamd failed with exit code eacces
    cordova build android Command failed with exit code EACCES
    Xcode 10 iOS12 "A valid provisioning profile for this executable was not found
    使用remix发布部署 发币 智能合约
    区块链: 编译发布智能合约
    mac 下常用命令备忘录
    JQuery fullCalendar 时间差 排序获取距当前最近的时间。
  • 原文地址:https://www.cnblogs.com/Shallow-dream/p/11520436.html
Copyright © 2011-2022 走看看