結果

問題 No.741 AscNumber(Easy)
ユーザー gazellegazelle
提出日時 2018-10-05 22:46:03
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,653 bytes
コンパイル時間 2,317 ms
コンパイル使用メモリ 196,244 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-20 17:25:33
合計ジャッジ時間 4,292 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#include<random>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back
#define MAX_N 1000010
long long extgcd(long long a, long long b, long long& x, long long& y) {
	long long d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1; y = 0;
	}
	return d;
}
long long mod_inverse(long long a, long long m) {
	long long x, y;
	if(extgcd(a, m, x, y) == 1) return (m + x % m) % m;
	else return -1;
}
vector<long long> fact(MAX_N+1, INF);
long long mod_fact(long long n, long long& e) {
	if(fact[0] == INF) {
		fact[0]=1;
		if(MAX_N != 0) fact[1]=1;
		for(ll i = 2; i <= MAX_N; ++i) {
			fact[i] = (fact[i-1] * i) % MOD;
		}
	}
	e = 0;
	if(n == 0) return 1;
	long long res = mod_fact(n / MOD, e);
	e += n / MOD;
	if((n / MOD) % 2 != 0) return (res * (MOD - fact[n % MOD])) % MOD;
	return (res * fact[n % MOD]) % MOD;
}
// return nCk
long long mod_comb(long long n, long long k) {
	if(n < 0 || k < 0 || n < k) return 0;
	long long e1, e2, e3;
	long long a1 = mod_fact(n, e1), a2 = mod_fact(k, e2), a3 = mod_fact(n - k, e3);
	if(e1 > e2 + e3) return 0;
	return (a1 * mod_inverse((a2 * a3) % MOD, MOD)) % MOD;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	cout<<mod_comb(n+9,9)<<endl;
	return 0;
}
0