52352023-04-23 16:16:25SleepyOverlordJáték (50 pont)cpp17Futási hiba 14/5048ms64184 KiB
#include <vector>
#include <string> 
#include <set> 
#include <map> 
#include <unordered_set>
#include <unordered_map>
#include <queue> 
#include <bitset> 
#include <stack>
#include <list>

#include <numeric> 
#include <algorithm> 
#include <random>
#include <chrono>

#include <cstdio>
#include <fstream>
#include <iostream> 
#include <sstream> 
#include <iomanip>
#include <climits>

#include <cctype>
#include <cmath> 
#include <ctime>
#include <cassert>

using namespace std;

#define ULL unsigned long long
#define LL long long
#define PII pair <int, int>
#define VB vector <bool>
#define VI vector <int>
#define VLL vector <LL>
#define VD vector <double>
#define VS vector <string>
#define VPII vector <pair <int, int> >
#define VVI vector < VI >
#define VVB vector < VB >
#define SI set < int >
#define USI unordered_set <int>
#define MII map <int, int>
#define UMII unordered_map <int, int>
#define MS multiset
#define US unordered_set
#define UM unordered_map
#define UMS unordered_multiset
#define UMM unordered_multimap

#define FORN(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)

#define SZ size()
#define BG begin() 
#define EN end() 
#define CL clear()
#define X first
#define Y second
#define RS resize
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(), x.end()
#define INS insert
#define ER erase
#define CNT count

const int MOD = 1e9 + 7;

int n, b, c;
vector <VVI> dp;

int main()
{
	cin >> b >> c;
	int n = c - b;
	dp.RS(c + 1, VVI(n + 1, VI(2)));
	FOR(j, 0, n) dp[0][j][1] = 1;
	FOR(i, 1, c)
		FOR(j, 0, n)
		{
			if (i - j >= b) continue;
			if (i > 0) dp[i][j][0] += dp[i - 1][j][0] + dp[i - 1][j][1];
			if (j > 0) dp[i][j][1] += dp[i][j - 1][0] + dp[i][j - 1][1];
			if (dp[i][j][0] >= MOD) dp[i][j][0] -= MOD;
			if (dp[i][j][1] >= MOD) dp[i][j][1] -= MOD;
		}

	int sum = 0;
	FOR(k, 0, c) sum = (sum + dp[k][n][1]) % MOD;
	cout << sum;

	return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base14/50
1Elfogadva0/03ms1816 KiB
2Elfogadva0/07ms6276 KiB
3Elfogadva2/23ms2248 KiB
4Elfogadva3/33ms2316 KiB
5Elfogadva3/33ms2508 KiB
6Elfogadva3/317ms18412 KiB
7Elfogadva3/324ms24928 KiB
8Futási hiba0/348ms64184 KiB
9Futási hiba0/343ms63940 KiB
10Futási hiba0/341ms63696 KiB
11Futási hiba0/346ms63664 KiB
12Futási hiba0/346ms63500 KiB
13Futási hiba0/346ms63428 KiB
14Futási hiba0/346ms63404 KiB
15Futási hiba0/346ms63400 KiB
16Futási hiba0/341ms63148 KiB
17Futási hiba0/341ms62952 KiB
18Futási hiba0/337ms62712 KiB
19Futási hiba0/337ms62712 KiB