Educational Codeforces Round 146 补题(A~C)
Educational Codeforces Round 146 (Rated for Div. 2)
A. Coins
题目大意
给你两个整数n和k,问你是否存在两个非负整数x和y,使得 2⋅x+k⋅y=n 成立
思路
裴蜀定理秒了,记得开long long
ac代码
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 inf = 8e18;
typedef pair<int, int> pii;
void solve() {
i64 n, k;
cin >> n >> k;
if (n % __gcd(2ll, k) == 0 && n >= min(2ll, k)) cout << "YES\n";
else cout << "NO\n";
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int t = 1;
cin >> t;
while (t --) solve();
return 0;
}
B. Long Legs
题目大意
一个机器人被放置在一个无限网格的
假设机器人当前位于
- 跳入
单元 - 跳入
单元; - 将腿的长度增加
,即设置为 。
机器人到达
思路
枚举
ac代码
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 inf = 8e18;
typedef pair<int, int> pii;
void solve() {
int a, b;
cin >> a >> b;
int ans = a + b;
for (int i = 1; i <= 100000; i ++)
ans = min(ans, i - 1 + (a + i - 1) / i + (b + i - 1) / i);
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int t = 1;
cin >> t;
while (t --) solve();
return 0;
}
C. Search in Parallel
题目大意
假设你有
你买了两个机器人来帮你取球。现在你必须给它们编程。为了给机器人编程,你必须构造两个列表
当您需要一个颜色为
思路
先根据取出的次数进行排序,如何根据当前查询时间的大小排进数组里
ac代码
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 inf = 8e18;
typedef pair<int, int> pii;
void solve() {
int n, s1, s2;
cin >> n >> s1 >> s2;
std::vector<pii> p(n);
for (int i = 0; i < n; i++) {
cin >> p[i].first;
p[i].second = i;
}
sort(p.begin(), p.end(), greater<pii>());
vector<int> ans[2];
int t1 = s1, t2 = s2;
for (int i = 0; i < n; i++) {
int j = i;
while (t1 <= t2 && j < n) ans[0].push_back(p[j ++].second + 1), t1 += s1;
while (t2 <= t1 && j < n) ans[1].push_back(p[j ++].second + 1), t2 += s2;
i = j - 1;
}
cout << ans[0].size() << ' ';
for (auto i : ans[0]) cout << i << ' ';
cout << '\n' << ans[1].size() << ' ';
for (auto i : ans[1]) cout << i << ' ';
cout << endl;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int t = 1;
cin >> t;
while (t --) solve();
return 0;
}
D. Balancing Weapons
太难了不想写
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具