結果

問題 No.3034 7 problems
ユーザー FF256grhyFF256grhy
提出日時 2018-04-02 18:44:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,044 bytes
コンパイル時間 1,426 ms
コンパイル使用メモリ 164,888 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-08 13:30:36
合計ジャッジ時間 5,066 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,380 KB
testcase_01 AC 4 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL MOD = 1e9 + 7;
LL ex(LL x, LL y, LL mod = MOD) {
	LL z[64], v = 1;
	inc(i, 64) { z[i] = (i == 0 ? x : z[i - 1] * z[i - 1] % mod); }
	inc(i, 64) { if((y >> i) & 1) { (v *= z[i]) %= mod; } }
	return v;
}

LL dp[100001];

/*
LL f1(LL n) { return n * n; }
LL f2(LL n) { return n * n * n - n + n * n; }
LL f3(LL n) { return (n == 1 ? 1 : 3); } // ???
LL f4(LL n) { return 4 * n * n + 17; }
LL f5(LL n) { return ex(n, n * n * n); }
LL f6(LL n) { return n; }
LL f7(LL n) { return (dp[n] * n) % MOD; }
*/

LL f1(LL n) { return (n * n) % MOD; }
LL f2(LL n) { return ((n * n * n) % MOD + (MOD - n) + n * n) % MOD; }
LL f3(LL n) { return (n == 1 ? 1 : 3); } // ???
LL f4(LL n) { return (4 * n * n + 17) % MOD; }
LL f5(LL n) { return ex(n, n * n * n); }
LL f6(LL n) { return n; }
LL f7(LL n) { return (dp[n] * n) % MOD; }


/*
4*10^26
xenon: Xe 54
2*10^2222
2^34
?????

Nchoutennnogurafugaaru.hajime,konogurafunihahennganai.konogurafuniN-1kaisousasuru.Ikaimenosousadeha[1,I]nohannideichiyourannsuuwomochiiteseisuuAwoseiseishi,choutennI+1tochoutennAnoaidanihennwotsuikasuru.sousagaowattaatonihakigadekiteiru.kokode,kinosukoawo,2ijouNikanosubetenoseisuuJnitsuitenochoutenn1tochoutennJnokyorinosouwatoteigisuru.ranndamunikouseisarerukinosukoanokitaichiwoXtoshitatoki,N!Xwo10^9+7dewattaamariwomotomenasai.tadashi,konoataihakanarazuseisuuninarukotogashoumeidekiru.

N 頂点のグラフがある。はじめ、このグラフには辺がない。このグラフに N-1 回操作する。
I 回目の操作では [1, I] の範囲で一様乱数を用いて整数 A を生成し、頂点 I+1 と頂点 A の間に辺を追加する。
操作が終わった後には木が出来ている。
ここで、木のスコアを、 2 以上 N 以下の全ての整数 J についての頂点 1 と頂点 J の距離の総和と定義する。
ランダムに構成される木のスコアの期待値を X としたとき、N!X を 10^9+7 で割った余りを求めなさい。
ただし、この値は必ず整数になることが証明できる。
*/

int main() {
	// dp[i] = OEIS_A001705[i - 1]
	// f7(i) = OEIS_A001705[i - 1] * i  (= OEIS_A006675[i])
	LL f = 1;
	inc1(i, 100000) {
		dp[i] = (i == 1 ? 0 : (dp[i - 1] * i + f) % MOD);
		(f *= i) %= MOD;
	}
	
	int t;
	cin >> t;
	inc(q, t) {
		if(q != 0) { cout << "\n"; }
		
		LL n;
		cin >> n;
		cout << f1(n) << "\n";
		cout << f2(n) << "\n";
		cout << f3(n) << "\n";
		cout << f4(n) << "\n";
		cout << f5(n) << "\n";
		cout << f6(n) << "\n";
		cout << f7(n) << "\n";
	}
	
	return 0;
}
0