結果

問題 No.1253 雀見椪
ユーザー chocoruskchocorusk
提出日時 2020-10-09 21:43:50
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 1,483 bytes
コンパイル時間 1,013 ms
コンパイル使用メモリ 129,296 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 16:00:12
合計ジャッジ時間 2,652 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 7 ms
4,376 KB
testcase_04 AC 65 ms
4,376 KB
testcase_05 AC 64 ms
4,380 KB
testcase_06 AC 64 ms
4,380 KB
testcase_07 AC 64 ms
4,376 KB
testcase_08 AC 61 ms
4,376 KB
testcase_09 AC 63 ms
4,376 KB
testcase_10 AC 63 ms
4,376 KB
testcase_11 AC 63 ms
4,376 KB
testcase_12 AC 63 ms
4,376 KB
testcase_13 AC 63 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[2000010], invf[2000010];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
    int t; cin>>t;
    while(t--){
        ll n, ag, bg, ac, bc, ap, bp;
        cin>>n>>ag>>bg>>ac>>bc>>ap>>bp;
        ll x=ag*inv(bg)%MOD;
        ll y=ac*inv(bc)%MOD;
        ll z=ap*inv(bp)%MOD;
        cout<<(1-powmod((x+y)%MOD, n)-powmod((y+z)%MOD, n)-powmod((z+x)%MOD, n)+3*MOD+2*(powmod(x, n)+powmod(y, n)+powmod(z, n)))%MOD<<endl;
    }
    return 0;
}
0