結果

問題 No.741 AscNumber(Easy)
ユーザー bal4ubal4u
提出日時 2019-05-12 22:48:55
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 1,518 ms
コンパイル使用メモリ 28,748 KB
実行使用メモリ 5,832 KB
最終ジャッジ日時 2023-09-19 06:22:49
合計ジャッジ時間 3,445 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
5,768 KB
testcase_01 AC 9 ms
5,832 KB
testcase_02 AC 9 ms
5,632 KB
testcase_03 AC 9 ms
5,832 KB
testcase_04 AC 9 ms
5,776 KB
testcase_05 AC 9 ms
5,732 KB
testcase_06 AC 9 ms
5,788 KB
testcase_07 AC 9 ms
5,632 KB
testcase_08 AC 9 ms
5,740 KB
testcase_09 AC 9 ms
5,692 KB
testcase_10 AC 8 ms
5,700 KB
testcase_11 AC 9 ms
5,728 KB
testcase_12 AC 9 ms
5,788 KB
testcase_13 AC 9 ms
5,728 KB
testcase_14 AC 9 ms
5,832 KB
testcase_15 AC 9 ms
5,732 KB
testcase_16 AC 9 ms
5,692 KB
testcase_17 AC 9 ms
5,744 KB
testcase_18 AC 9 ms
5,748 KB
testcase_19 AC 9 ms
5,728 KB
testcase_20 AC 9 ms
5,744 KB
testcase_21 AC 9 ms
5,692 KB
testcase_22 AC 8 ms
5,688 KB
testcase_23 AC 9 ms
5,748 KB
testcase_24 AC 9 ms
5,824 KB
testcase_25 AC 9 ms
5,692 KB
testcase_26 AC 8 ms
5,728 KB
testcase_27 AC 9 ms
5,632 KB
testcase_28 AC 9 ms
5,692 KB
testcase_29 AC 9 ms
5,720 KB
testcase_30 AC 9 ms
5,700 KB
testcase_31 AC 9 ms
5,728 KB
testcase_32 AC 9 ms
5,736 KB
testcase_33 AC 9 ms
5,824 KB
testcase_34 AC 8 ms
5,764 KB
testcase_35 AC 9 ms
5,700 KB
testcase_36 AC 9 ms
5,732 KB
testcase_37 AC 8 ms
5,692 KB
testcase_38 AC 9 ms
5,628 KB
testcase_39 AC 9 ms
5,736 KB
testcase_40 AC 9 ms
5,696 KB
testcase_41 AC 9 ms
5,740 KB
testcase_42 AC 8 ms
5,732 KB
testcase_43 AC 8 ms
5,696 KB
testcase_44 AC 9 ms
5,628 KB
testcase_45 AC 9 ms
5,760 KB
testcase_46 AC 9 ms
5,736 KB
testcase_47 AC 9 ms
5,688 KB
testcase_48 AC 9 ms
5,696 KB
testcase_49 AC 9 ms
5,732 KB
testcase_50 AC 9 ms
5,748 KB
testcase_51 AC 9 ms
5,824 KB
testcase_52 AC 8 ms
5,728 KB
testcase_53 AC 9 ms
5,692 KB
testcase_54 AC 9 ms
5,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#include <stdio.h>

typedef long long ll;

#define M 1000000007
#define MAX 1000020

int fact[MAX+2];

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

int inverse(int a) {
    int x, y;
    ext_gcd(a, M, &x, &y);
	return (x + M) % M;
}

int comb(int n) {
    return (ll)fact[n+9] * inverse((int)((ll)fact[9]*fact[n] % M)) % M;
}

int main()
{
	int i, N;

	fact[0] = 1; for (i = 1; i <= MAX; i++) fact[i] = ((ll)fact[i-1]*i) % M;
	scanf("%d", &N);
    printf("%d\n", comb(N));
	return 0;
}
0