11.25 周一日常
1.2025.2.19——15002.11.23 周六3.11.24 周日
4.11.25 周一日常
5.2024.11.26 周二日常6.2024.11.27 周三7.2024.11.28周四8.2024.11.29 周五9.2024.11.30 周六10.2024.12.1 周日11.2024.12.2 周一12.2024.12.3 周二13.2024.12.4 周三14.2024.12.5 周四15.2024.12.7 周六16.2024.12.8 周日17.2024.12.9 周一18.2024.12.10 周二19.2024.12.11 周三20.2024.12.12 周四21.2024.12.13 周五22.2024.12.14 周六23.2024.12.16 周一24.2024.12.17 周二25.2024.12.18 周三26.2024.12.19 周四27.2024.12.20 周五28.2024.12.21 周六29.2024.12.22 周日30.2024.12.23 周一31.2024.12.24 周四32.2024.12.25 周三33.2024.12.26 周四34.2024.12.27 周五35.2024.12.28 周六36.2024.12.29 周日37.2024.12.30 周一38.2025.1.5——120039.2025.1.12——120040.2025.1.14——120041.2025.1.15——120042.2025.1.16——120043.2025.1.17——120044.2025.1.18——130045.2025.1.19——130046.2025.1.20——130047.2025.1.21——130048.2025.1.22——130049.2025.1.24——140050.2025.1.26——140051.2025.2.8——140052.2025.2.9——140053.2025.2.10——140054.2025.2.14——140055.2025.2.15——140056.2025.2.17——140011.25 周一 日常
Q1. 1200 给定x,y,k,k次操作,每次操作:x++,若x可被y整除,x一直除以y。问最终x的值。(x,y,k≤1e9)
Q2. 1400 给定一等差数列a,每次操作:令最大值=mex{a}。问是否可以将a变成0~n-1的排列和最小操作次数。(1e18)
Q3. 1600 给定一数组和lim,设操作l,r:i:l->r,令s=0,s+=a[i];每一步如果s>lim,s=0。问使s最终不为0,l,r的方案数。
A1. 补 A2. 37mins-44mins A3. 补
A1. 加速操作:每次让x加到下一个能被y整除到的值。在O(log(x))内x=1,即关键点。发现继续操作答案有规律1,2,3,...,y-1。
A2. 数学推式子,公差不为0时发现答案为(c+(b-1)*n)/b (判上限且需要__int128) / n-max(0,1+(n-c-1)/b),公差为0时,即n个相同的数,模拟一下发现n<=c+2时有解,再分类讨论答案。
A3. 令f[i]:左端点选择i的合法方案数,j为右侧最近使s==0的点。转移:f[i]=f[j+1]+j-i; 答案就是f[i]的和。二分加前缀和找j,边界细节。
A1.
#include <bits/stdc++.h>
#define int long long //
#define endl '\n' //
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
const int mod = 998244353;
const int N = 10 + 5e5;
void _();
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--)
_();
return 0;
}
// 补
void _()
{
int x, y, k;
cin >> x >> y >> k;
while (x - 1)
{
int cnt = min(k, y - x % y);
k -= cnt;
x += cnt;
while (x % y == 0)
x /= y;
if (!k)
break;
}
if (k)
{
k %= y - 1;
x = k + 1;
}
cout << x << endl;
}
// 1.
// void _()
// {
// int x, y, k;
// cin >> x >> y >> k;
// while (x - 1)
// {
// int cnt = y - x % y;
// if (cnt <= k)
// {
// k -= cnt;
// x += cnt;
// while (x % y == 0)
// x /= y;
// }
// else
// break;
// }
// if (k)
// {
// if (x - 1)
// x += k;
// else
// {
// k %= y - 1;
// x = k + 1;
// }
// }
// cout << x << endl;
// }
**A2. **
#include <bits/stdc++.h>
// #define int long long //
#define int __int128
#define endl '\n' //
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
const int mod = 998244353;
const int N = 10 + 5e5;
void _();
int re()
{
int s = 0, f = 1;
char ch = getchar();
while (ch > '9' || ch < '0')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while ('0' <= ch && ch <= '9')
s = s * 10 + ch - 48, ch = getchar();
return s * f;
}
void wr(int s)
{
if (s < 0)
putchar('-'), s = -s;
if (s > 9)
wr(s / 10);
putchar(s % 10 + 48);
}
void wr(int s, char ch) { wr(s), putchar(ch); }
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
t = re();
while (t--)
_();
return 0;
}
// 37min-44min
void _()
{
int n, b, c;
n = re(), b = re(), c = re();
// cin >> n >> b >> c;
int res = 0; // n - max(0ll, 1 + (n - c - 1) / b)
if (b)
res = min(n, (c + (b - 1) * n) / b);
else
{
if (n <= c + 2)
{
res = n;
if (n > c)
res--;
}
else
res = -1;
}
wr(res, '\n');
}
A3.
#include <bits/stdc++.h>
#define int long long //
#define endl '\n' // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int T = 1;
cin >> T;
while (T--)
_();
return 0;
}
// 补
void _()
{
int n, k;
cin >> n >> k;
vector<int> a(n + 1), pre(n + 2);
for (int i = 1; i <= n; i++)
cin >> a[i], pre[i] = pre[i - 1] + a[i];
vector<int> f(n + 3);
int res = 0;
for (int i = n; i; i--)
{
int l = i - 1, r = n + 1;
while (r - l - 1)
{
int mid = l + r >> 1;
if (pre[mid] - pre[i - 1] > k)
r = mid;
else
l = mid;
}
res += f[i] = f[r + 1] + r - i;
}
cout << res << endl;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!