結果

問題 No.741 AscNumber(Easy)
ユーザー gazellegazelle
提出日時 2018-10-05 22:45:31
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,653 bytes
コンパイル時間 2,521 ms
コンパイル使用メモリ 200,588 KB
実行使用メモリ 10,796 KB
最終ジャッジ日時 2023-08-02 17:17:39
合計ジャッジ時間 4,253 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
10,732 KB
testcase_01 AC 10 ms
10,592 KB
testcase_02 AC 10 ms
10,640 KB
testcase_03 AC 10 ms
10,644 KB
testcase_04 AC 10 ms
10,700 KB
testcase_05 AC 10 ms
10,640 KB
testcase_06 AC 10 ms
10,716 KB
testcase_07 AC 9 ms
10,596 KB
testcase_08 AC 10 ms
10,772 KB
testcase_09 AC 10 ms
10,596 KB
testcase_10 AC 10 ms
10,780 KB
testcase_11 AC 11 ms
10,516 KB
testcase_12 AC 10 ms
10,520 KB
testcase_13 AC 10 ms
10,712 KB
testcase_14 AC 10 ms
10,676 KB
testcase_15 AC 10 ms
10,716 KB
testcase_16 AC 10 ms
10,596 KB
testcase_17 AC 10 ms
10,796 KB
testcase_18 AC 10 ms
10,612 KB
testcase_19 AC 9 ms
10,520 KB
testcase_20 AC 10 ms
10,736 KB
testcase_21 AC 10 ms
10,768 KB
testcase_22 AC 10 ms
10,520 KB
testcase_23 AC 10 ms
10,664 KB
testcase_24 AC 10 ms
10,744 KB
testcase_25 AC 10 ms
10,520 KB
testcase_26 AC 10 ms
10,712 KB
testcase_27 AC 11 ms
10,532 KB
testcase_28 AC 10 ms
10,516 KB
testcase_29 AC 10 ms
10,648 KB
testcase_30 AC 9 ms
10,732 KB
testcase_31 AC 10 ms
10,668 KB
testcase_32 AC 10 ms
10,612 KB
testcase_33 AC 10 ms
10,736 KB
testcase_34 AC 10 ms
10,524 KB
testcase_35 AC 10 ms
10,672 KB
testcase_36 AC 10 ms
10,780 KB
testcase_37 AC 9 ms
10,612 KB
testcase_38 AC 10 ms
10,644 KB
testcase_39 AC 10 ms
10,732 KB
testcase_40 AC 10 ms
10,600 KB
testcase_41 AC 10 ms
10,768 KB
testcase_42 AC 11 ms
10,600 KB
testcase_43 AC 11 ms
10,588 KB
testcase_44 AC 9 ms
10,672 KB
testcase_45 AC 10 ms
10,716 KB
testcase_46 AC 10 ms
10,612 KB
testcase_47 AC 10 ms
10,540 KB
testcase_48 AC 10 ms
10,640 KB
testcase_49 AC 10 ms
10,524 KB
testcase_50 AC 11 ms
10,780 KB
testcase_51 AC 10 ms
10,692 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 9 ms
10,724 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 1000000
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