結果

問題 No.741 AscNumber(Easy)
ユーザー bal4u
提出日時 2019-05-12 22:48:55
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 29,952 KB
実行使用メモリ 5,760 KB
最終ジャッジ日時 2024-07-05 18:35:58
合計ジャッジ時間 2,586 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 55
権限があれば一括ダウンロードができます

ソースコード

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