結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 0 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 0 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 0 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 0 ms
4,380 KB
testcase_21 AC 0 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 0 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 0 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 0 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 0 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 0 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 0 ms
4,376 KB
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 1 ms
4,376 KB
testcase_50 AC 0 ms
4,376 KB
testcase_51 AC 0 ms
4,376 KB
testcase_52 AC 1 ms
4,380 KB
testcase_53 AC 1 ms
4,380 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[101] = {
1,531950728,368774859,548996970,422550956,737935835,309944332,296716438,65533322,851076783,457992974,
559938709,118586228,177829816,830760447,240586351,611862881,267145356,334356152,706226766,107146451,
469491375,469619345,630906046,658967159,50180518,287209856,372045574,702584502,210306242,373281933,
330131954,179035946,642845435,293008185,889591949,832275593,783222990,698245208,968856847,559805077,
612250579,425371772,408721018,227278675,231684727,711739673,93615261,795156156,111810641,154425679,
950741508,384634755,797824545,581839401,899281002,343434222,924042332,973241307,253333132,679209364,
663967499,840761205,567656070,152546903,44613330,82447511,402958911,571952764,757842436,526226141,
184978106,402043945,99111089,19484938,419049924,253026585,713158286,874682245,220437571,644158465,
63869907,114643102,972816308,728256514,963945752,933338751,18380550,857887831,720850066,730342129,
178869710,711198175,194146825,768522507,643362481,281968565,947088120,949574384,121835953,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/10000]; for (i = n/10000*10000+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 i, N;

	scanf("%d", &N);
	calc(N);
	printf("%d\n", (int)((ll)pn9 * inverse((int)((ll)pn * P9 % M)) % M));
	return 0;
}
0