結果

問題 No.616 へんなソート
ユーザー warabi0906warabi0906
提出日時 2023-03-03 12:57:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 3,536 bytes
コンパイル時間 4,674 ms
コンパイル使用メモリ 233,704 KB
実行使用メモリ 57,980 KB
最終ジャッジ日時 2023-10-18 00:57:24
合計ジャッジ時間 5,341 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 37 ms
21,496 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 20 ms
12,256 KB
testcase_18 AC 4 ms
4,600 KB
testcase_19 AC 5 ms
4,864 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 116 ms
57,980 KB
testcase_29 AC 113 ms
57,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include "atcoder/all"
#define debug cout << "OK" << endl;
template<typename T>
inline bool chmax(T& a, const T b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
inline bool chmin(T& a, const T b) { if (a > b) { a = b; return true; } return false; }
inline int Code(char c) {
	if ('A' <= c and c <= 'Z')return (int)(c - 'A');
	if ('a' <= c and c <= 'z')return (int)(c - 'a');
	if ('0' <= c and c <= '9')return (int)(c - '0');
	assert(false);
}
inline long long sigma(const long long begin, const long long end, const long long mod = (1LL << 60)) {
	long long t = (begin + end) % mod;
	long long l = (end - begin + 1) % mod;
	return (t * l / 2) % mod;
}
using namespace std;
using namespace atcoder;
using minit = modint1000000007;
using minit2 = modint998244353;
constexpr int MOD = 1000000007;
constexpr int MOD2 = 998244353;
constexpr long long INF = 1e18;

template<typename T>
ostream& operator << (ostream& st, const vector<T>& v) {
	for (const T value : v) {
		st << value << " ";
	}
	return st;
}
template<typename T>
istream& operator >> (istream& st, vector<T>& v) {
	for (T& value : v) {
		st >> value;
	}
	return st;
}

long long pow_(const long long a, const long long b, const long long m = INF) {
	long long res = 1;
	long long base = a;
	for (int i = 0; i < 64; i++) {
		if (b & (1ll << i))res *= base;
		res %= m;
		base = base * base;
		base %= m;
	}
	return res;
}
inline int gcd(const int a, const int b) { return (b == 0 ? a : gcd(b, a % b)); }
inline int lcm(const int a, const int b) { return a * b / gcd(a, b); }
//
int Div(int a, int b, int m) {
	return (a * pow_(b, m - 2, m)) % m;
}
class nCk {
public:
	vector<long long> fact, fact_inv, inv;
	long long m;
	/*  init_nCk :二項係数のための前処理
		計算量:O(n)
	*/
	void init_nCk(int SIZE,int mod) {
		m = mod;
		fact.resize(SIZE + 5);
		fact_inv.resize(SIZE + 5);
		inv.resize(SIZE + 5);
		fact[0] = fact[1] = 1;
		fact_inv[0] = fact_inv[1] = 1;
		inv[1] = 1;
		for (int i = 2; i < SIZE + 5; i++) {
			fact[i] = fact[i - 1] * i % m;
			inv[i] = m - inv[m % i] * (m / i) % m;
			fact_inv[i] = fact_inv[i - 1] * inv[i] % m;
		}
	}
	/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
		計算量:O(1)
	*/
	long long com(int n, int k) {
		assert(!(n < k));
		assert(!(n < 0 || k < 0));
		return fact[n] * (fact_inv[k] * fact_inv[n - k] % m) % m;
	}
};
//

class Solver {
public:
	int T;
	Solver() :T(1) {}
	~Solver(){}
	void ios()const;
	void multi();
	void solve() const;
	void sp(int x)const;
	void ft()const;

	//
	
	//
};
void Solver::ios() const {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	return;
}
void Solver::multi() {
	cin >> T;
	return;
}
void Solver::sp(const int x)const {
	cout << fixed << setprecision(x) << endl;
	return;
}

void Solver::ft() const {
	
}
void Solver::solve() const {
	long long N, K;
	cin >> N >> K;
	vector<vector<minit>> DP(N + 3, vector<minit>(K + N + 10, 0));
	DP[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= K; j++) {
			DP[i + 1][j] += DP[i][j];
			DP[i + 1][j + i + 1] -= DP[i][j];
		}
		for (int j = 0; j <= K + N; j++)DP[i + 1][j + 1] += DP[i + 1][j];
	}
	minit ans = 0;
	for (int i = 0; i <= K; i++) {
		ans += DP[N][i];
	}
	cout << ans.val() << endl;
}

signed main() {
	Solver solver;
	solver.ios();
	//solver.ft();
	//solver.multi();
	//solver.sp();
	for (int i = 0; i < solver.T; i++)
		solver.solve();
	return 0;
}

/*
* わらびのコードこーどすぺーす
 (σ・∀・)σゲッツ!!
*/
0