Please sign in first.
Submission #60605080
Source Code Expand
// LUOGU_RID: 193663705
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 1e5 + 5;
constexpr ll MOD = 1e9 + 7;
array<ll, N> f;
int n, m;
int main()
{
ios::sync_with_stdio(0), cin.tie(0);
cin >> n >> m;
for (int i = 0; i <= m; i += n) f[i] = 1;
auto ins = [&](ll x)
{
for (ll i = x; i <= m; i++)
{
f[i] += f[i - x];
f[i] >= MOD ? f[i] -= MOD : 0;
}
};
auto del = [&](ll x)
{
for (ll i = m; i >= x; i--)
{
f[i] = (f[i] - f[i - x] + MOD);
f[i] >= MOD ? f[i] -= MOD : 0;
}
};
auto query = [&](int x)->ll
{
return 1ll * x * (x + 1) / 2;
};
for (int i = 1; i < n; i++) ins(query(i));
ll ans = 0ll;
for (int i = 1; i <= n; i++)
{
ll tot = query(i - 1);
if (tot <= m) ans += f[m - tot];
ans >= MOD ? ans -= MOD : 0;
if (i == n) break;
// (i,n]
del(query(n - i));
// [1,i]
ins(query(i));
}
cout << ans << "\n";
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Convex Sequence |
| User | hahasha |
| Language | C++ 20 (gcc 12.2) |
| Score | 1000 |
| Code Size | 918 Byte |
| Status | AC |
| Exec Time | 59 ms |
| Memory | 4404 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 1000 / 1000 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt |
| All | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt, 01-026.txt, 01-027.txt, 01-028.txt, 01-029.txt, 01-030.txt, 01-031.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-001.txt | AC | 1 ms | 3520 KiB |
| 00-sample-002.txt | AC | 1 ms | 3516 KiB |
| 00-sample-003.txt | AC | 59 ms | 4216 KiB |
| 01-001.txt | AC | 1 ms | 3988 KiB |
| 01-002.txt | AC | 1 ms | 3844 KiB |
| 01-003.txt | AC | 1 ms | 3612 KiB |
| 01-004.txt | AC | 1 ms | 3576 KiB |
| 01-005.txt | AC | 1 ms | 3776 KiB |
| 01-006.txt | AC | 4 ms | 3632 KiB |
| 01-007.txt | AC | 10 ms | 3740 KiB |
| 01-008.txt | AC | 43 ms | 4152 KiB |
| 01-009.txt | AC | 51 ms | 4228 KiB |
| 01-010.txt | AC | 1 ms | 3604 KiB |
| 01-011.txt | AC | 1 ms | 3648 KiB |
| 01-012.txt | AC | 9 ms | 3820 KiB |
| 01-013.txt | AC | 2 ms | 3492 KiB |
| 01-014.txt | AC | 29 ms | 3900 KiB |
| 01-015.txt | AC | 20 ms | 3804 KiB |
| 01-016.txt | AC | 8 ms | 4304 KiB |
| 01-017.txt | AC | 19 ms | 4304 KiB |
| 01-018.txt | AC | 11 ms | 4204 KiB |
| 01-019.txt | AC | 9 ms | 4192 KiB |
| 01-020.txt | AC | 9 ms | 4384 KiB |
| 01-021.txt | AC | 34 ms | 4192 KiB |
| 01-022.txt | AC | 53 ms | 4304 KiB |
| 01-023.txt | AC | 58 ms | 4200 KiB |
| 01-024.txt | AC | 58 ms | 4304 KiB |
| 01-025.txt | AC | 24 ms | 4300 KiB |
| 01-026.txt | AC | 58 ms | 4304 KiB |
| 01-027.txt | AC | 59 ms | 4200 KiB |
| 01-028.txt | AC | 59 ms | 4360 KiB |
| 01-029.txt | AC | 59 ms | 4384 KiB |
| 01-030.txt | AC | 58 ms | 4404 KiB |
| 01-031.txt | AC | 59 ms | 4300 KiB |