結果

問題 No.1253 雀見椪
ユーザー kenta255kenta255
提出日時 2020-10-10 09:36:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 3,244 bytes
コンパイル時間 3,045 ms
コンパイル使用メモリ 209,272 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-20 15:40:28
合計ジャッジ時間 4,473 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 12 ms
5,376 KB
testcase_04 AC 149 ms
5,376 KB
testcase_05 AC 151 ms
5,376 KB
testcase_06 AC 151 ms
5,376 KB
testcase_07 AC 150 ms
5,376 KB
testcase_08 AC 150 ms
5,376 KB
testcase_09 AC 150 ms
5,376 KB
testcase_10 AC 163 ms
5,376 KB
testcase_11 AC 151 ms
5,376 KB
testcase_12 AC 152 ms
5,376 KB
testcase_13 AC 150 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*b);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}


class comb{
	vector<ll> f,fr;
	ll MOD_;
	public:
	//a^(p-1) = 1 (mod p)(p->Prime numbers)
	//a^(p-2) = a^(-1)
	ll calc(ll a,ll b,ll p){//a^(b) mod p   
		if(b==0)return 1;
		ll y = calc(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % p;
		return y;
	}
	void init(ll n,ll mod){//input max_n
		MOD_ = mod;
		f.resize(n+1);
		fr.resize(n+1);
		f[0]=fr[0]=1;
		for(ll i=1;i<n+1;i++){
			f[i] = (f[i-1] * i) % mod;
		}
		fr[n] = calc(f[n],mod-2,mod);
		for(ll i=n-1;i>=0;i--){
			fr[i] = fr[i+1] * (i+1) % mod;
		}
	}
	ll nCr(ll n,ll r){
		if(n<0||r<0||n<r)return 0;
		return f[n] * fr[r] % MOD_ * fr[n-r] % MOD_;
	}//nHr = n+r-1Cr
};

class modll{
public:
	ll v,m;
	modll(ll v=0,ll m=MOD):v(v),m(m){}
	modll operator + (modll p) {return modll( ( v + p.v ) % m , m );}
	modll operator - (modll p) {return modll( ( v + p.m - p.v ) % p.m , m );}
	modll operator * (modll a) {return modll(v * a.v % a.m, a.m);}
	modll operator / (modll a) {return modll(v * calcm(a.v,a.m-2,a.m) % a.m , m );}
	modll operator ^ (modll a) {return modll(calcm(v,a.v,a.m),a.m);}
	modll operator + (ll p) {return modll( ( v + p ) % m , m );}
	modll operator - (ll p) {return modll( ( v + m - p ) % m , m );}
	modll operator * (ll p) {return modll( ( v * p ) % m , m );}
	modll operator / (ll a) {return modll(v*calcm(a,m-2,m)%m,m);}
	modll operator ^ (ll a) {return modll(calcm(v,a,m),m);}
	ll calcm(ll a,ll b,ll p){//a^(b) mod p   
		if(b==0)return 1;
		ll y = calcm(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % p;
		return y;
	}
};
ll calc(ll a,ll b,ll p){//a^(b) mod p   
	if(b==0)return 1;
	ll y = calc(a,b/2,p);y=(y*y)%p;
	if(b & 1) y = (y * a) % p;
	return y;
}
modll mpow(modll a,modll b){
	return modll(calc(a.v,b.v,a.m),a.m);
}


int main(){

	ll T;
	cin >> T;
	FOR(t,0,T){
		modll N;
		vector<modll> A(3),B(3);
		cin >> N.v;
		N.m = MOD;
		FOR(i,0,3) cin >> A[i].v >> B[i].v;
		FOR(i,0,3) A[i].m = B[i].m = MOD; 
		modll only0 = (A[0] / B[0]) ^ N;
		modll only1 = (A[1] / B[1]) ^ N;
		modll only2 = (A[2] / B[2]) ^ N;
		modll not0 = (modll(1,MOD) - (A[0] / B[0])) ^ N;
		modll not1 = (modll(1,MOD) - (A[1] / B[1])) ^ N;
		modll not2 = (modll(1,MOD) - (A[2] / B[2])) ^ N;
		modll ans = not0+not1+not2-only1-only1-only0-only0-only2-only2;;
		ans = modll(1,MOD) - ans;
		cout << ans.v << endl;
	}

}

0