• Gym 101480F Frightful Formula(待定系数)题解


    #include<cmath>
    #include<set>
    #include<map>
    #include<queue>
    #include<cstdio>
    #include<vector>
    #include<cstring>
    #include <iostream>
    #include<algorithm>
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    const int maxn = 2e5 + 10;
    const int M = maxn * 30;
    const ull seed = 131;
    const int INF = 0x3f3f3f3f;
    const int MOD = 1e6 + 3;
    ll inv[maxn << 1], fac[maxn << 1];
    ll ppow(ll a, ll b){
        ll ret = 1;
        while(b){
            if(b & 1) ret = ret * a % MOD;
            a = a * a % MOD;
            b >>= 1;
        }
        return ret;
    }
    void init(int n){
        fac[0] = inv[0] = 1;
        for(int i = 1; i <= n; i++)
            fac[i] = fac[i - 1] * i % MOD;
        inv[n] = ppow(fac[n], MOD - 2);
        for(int i = n - 1; i >= 1; i--){
            inv[i] = inv[i + 1] * (i + 1LL) % MOD;
        }
    }
    ll C(int n, int m){
        if(m == 0) return 1;
        return fac[n] * inv[m] % MOD * inv[n - m] % MOD;
    }
    ll l[maxn], t[maxn];
    ll dp[1000][1000];
    int main(){
        ll n, a, b, c;
        scanf("%lld%lld%lld%lld", &n, &a, &b, &c);
        init(n + n);
        ll k = c * ppow(a + b - 1, MOD - 2) % MOD;
        ll ans = 0;
        for(int i = 1; i <= n; i++)
            scanf("%lld", &l[i]), l[i] = (l[i] + k) % MOD;
        for(int i = 1; i <= n; i++)
            scanf("%lld", &t[i]), t[i] = (t[i] + k) % MOD;
        for(int i = 2; i <= n; i++){
            ans = (ans + l[i] * C(n + n - i - 2, n - 2) % MOD * ppow(a, n - 1) % MOD * ppow(b, n - i) % MOD) % MOD;
    //        printf("** %lld %lld
    ", n + n - i - 2, n - 2);
        }
        for(int i = 2; i <= n; i++){
            ans = (ans + t[i] * C(n + n - i - 2, n - 2) % MOD * ppow(a, n - i) % MOD * ppow(b, n - 1) % MOD) % MOD;
        }
        ans = ((ans - k) % MOD + MOD) % MOD;
        printf("%lld
    ", ans);
        return 0;
    }
    /*
    4 3 5 2
    7 1 4 3
    7 4 4 8
    */
    /*
    3 2 3 0
    1 1 1
    1 1 1
    */
  • 相关阅读:
    【转】软链接和硬链接到底有啥作用和区别
    useradd命令详解
    【转】Linux下MySQL数据库安装及配置方法
    【转】MySQL的安装与配置——详细教程-window系统下
    mysql服务器常用命令
    【转】DDL/DML/DCL区别概述
    tmux终端工具的简单使用
    linux go环境安装和基本项目结构
    ClickHouse高可用集群的配置
    centos7下使用rpm包安装clickhouse
  • 原文地址:https://www.cnblogs.com/KirinSB/p/10822110.html
Copyright © 2020-2023  润新知