結果

問題 No.741 AscNumber(Easy)
ユーザー bal4ubal4u
提出日時 2019-05-13 07:05:38
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 2,780 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 29,192 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 17:38:59
合計ジャッジ時間 2,394 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// yukicoder: No.741 AscNumber(Easy)
// 2019.5.12 bal4u

#include <stdio.h>

typedef long long ll;

#define M 1000000007
#define MAX 1000020
#define P9 362880  // 9!
int tbl[201] = {
1,541108809,531950728,576865589,368774859,232201666,548996970,835874618,422550956,820210693,737935835,
553695703,309944332,392352826,296716438,796945456,65533322,840311971,851076783,978160598,457992974,
755011148,559938709,436467039,118586228,319001333,177829816,653893017,830760447,190233572,240586351,
198661311,611862881,456839561,267145356,312778040,334356152,640326947,706226766,678649477,107146451,
219920862,469491375,649693772,469619345,660136491,630906046,6260416,658967159,987459542,50180518,
456901092,287209856,839142168,372045574,389741527,702584502,305275963,210306242,564464342,373281933,
243959960,330131954,980418272,179035946,345832821,642845435,514145995,293008185,784412643,889591949,
101532178,832275593,816594770,783222990,948901511,698245208,695232868,968856847,902461680,559805077,
856005428,612250579,359405516,425371772,663019841,408721018,544799669,227278675,879019034,231684727,
823744253,711739673,535260540,93615261,365882953,795156156,125749926,111810641,298448241,154425679,
387646221,950741508,637461484,384634755,45824090,797824545,288222406,581839401,606242968,899281002,
877036688,343434222,792695537,924042332,886642171,973241307,56956114,253333132,484733770,679209364,
473989428,663967499,665612111,840761205,783459896,567656070,677098815,152546903,707642533,44613330,
780803591,82447511,664902098,402958911,868744334,571952764,812822843,757842436,378912980,526226141,
588225665,184978106,882183133,402043945,876694648,99111089,162275749,19484938,591294196,419049924,
440494651,253026585,774239862,713158286,495053769,874682245,554416598,220437571,257287349,644158465,
579800026,63869907,738614905,114643102,520707075,972816308,993584556,728256514,605410958,963945752,
552007909,933338751,656978107,18380550,387063299,857887831,751827693,720850066,609061024,730342129,
631737004,178869710,301648647,711198175,35126335,194146825,860739395,768522507,736473025,643362481,
633835834,281968565,233583164,947088120,587408713,949574384,479758791,121835953,642457172,641102369};

int ex_gcd(int a, int b, int *x, int *y) {
	int d;
	if (b == 0) { *x = 1; *y = 0; return a; }
	d = ex_gcd(b, a % b, y, x);
	*y -= a / b * (*x);
	return d;
}

int inverse(int a) {
    int x, y;
    ex_gcd(a, M, &x, &y);
	if (x < 0) x += M;
	return x;
}

int pn, pn9;   // n!, (n+9)!
void calc(int n) {
	int i;
	pn = tbl[n/5000]; for (i = n/5000*5000+1; i <= n; i++) pn = (ll)pn * i % M;
	pn9 = pn, n += 9; for ( ; i <= n; i++) pn9 = (ll)pn9 * i % M;
}
		
int main()
{
	int N;
	scanf("%d", &N);
	calc(N);
	printf("%d\n", (int)((ll)pn9 * inverse((int)((ll)pn * P9 % M)) % M));
	return 0;
}
0