結果

問題 No.1253 雀見椪
ユーザー face4face4
提出日時 2020-10-10 20:14:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 699 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 64,616 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 22:35:39
合計ジャッジ時間 3,763 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
using namespace std;

typedef long long ll;
const ll mod = 1000000007;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

int main(){
    int t;
    cin >> t;
    while(t--){
        ll n, a[3], b[3];
        cin >> n;
        for(int i = 0; i < 3; i++)  cin >> a[i] >> b[i], a[i] = a[i]*modpow(b[i],mod-2)%mod;
        ll ans = 0;
        for(int i = 0; i < 3; i++)  (ans += modpow(a[i]+a[(i+1)%3], n)-modpow(a[i], n)-modpow(a[(i+1)%3], n)+mod+mod) %= mod;
        cout << (1-ans+mod)%mod << endl;
    }
    return 0;
}
0