feat: new TLE solution implemented
This commit is contained in:
@@ -45,7 +45,7 @@
|
||||
"main-ac": "ac.cpp",
|
||||
"alternative-ac": [],
|
||||
"wrong-answer": [],
|
||||
"time-limit": [],
|
||||
"time-limit": ["TLE.cpp"],
|
||||
"time-limit-or-ac": [],
|
||||
"time-limit-or-memory-limit": [],
|
||||
"memory-limit": [],
|
||||
|
||||
46
analise-de-dados/src/TLE.cpp
Normal file
46
analise-de-dados/src/TLE.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
typedef long long ll;
|
||||
using namespace std;
|
||||
|
||||
const int MOD = 1e9 + 7;
|
||||
int N;
|
||||
vector<int> rollMax(7);
|
||||
|
||||
ll die(int size, int count, int last)
|
||||
{
|
||||
if (size == N) return 1;
|
||||
|
||||
ll ans = 0;
|
||||
if (count < rollMax[last])
|
||||
ans += die(size + 1, count + 1, last);
|
||||
|
||||
for (int i = 1; i <= 6; i++) {
|
||||
if (i != last) {
|
||||
ans += die(size + 1, 1, i);
|
||||
ans %= MOD;
|
||||
}
|
||||
}
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
int dieSimulator()
|
||||
{
|
||||
ll ans = 0;
|
||||
for (int i = 1; i <= 6; i++)
|
||||
{
|
||||
ans += die(1, 1, i);
|
||||
ans %= MOD;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
cin >> N;
|
||||
for (int i = 1; i <= 6; i++)
|
||||
cin >> rollMax[i];
|
||||
cout << dieSimulator() << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user