B. A Balanced Problemset
1.C. Insert and Equalize2.C. Removal of Unattractive Pairs3.D. Jumping Through Segments4.E. Good Triples5.F. Shift and Reverse6.D. Yet Another Monster Fight7.A. Constructive Problems8.C. Game with Multiset9.A. Rating Increase10.B. Swap and Delete11.A. Problemsolving Log12.B. Preparing for the Contest13.C. Quests14.D. Three Activities15.E2. Game with Marbles (Hard Version)16.cf刷题有感17.A. Anonymous Informant18.A. Forked!19.B. Make Almost Equal With Mod20.C. Heavy Intervals21.D. Split Plus K22.A. 202323.B. Two Divisors24.C. Training Before the Olympiad25.D. Mathematical Problem26.F. Greetings27.C. Partitioning the Array28.G. Bicycles29.E. Eat the Chip30.G. Lights31.D. Array Repetition32.D. Berserk Monsters33.E. Increasing Subsequences34.D. Very Different Array35.G. Mischievous Shooter36.B. Plus-Minus Split
37.B. A Balanced Problemset
38.C. Did We Get Everything Covered39.D. Find the Different Ones!40.C. Grouping Increases41.D. Good Trip42.C. Physical Education Lesson43.E. Final Countdown44.D. Divisible Pairs45.G. Vlad and Trouble at MIT46.A. Brick Wall47.B. Minimize Inversions48.C. XOR-distance49.A. Moving Chips50.B. Monsters Attack!51.C. Find B52.D. Slimes53.C. Turtle Fingers: Count the Values of k54.D. Turtle Tenacity: Continual Mods55.D. Vlad and Division56.C. LR-remainders57.D. Lonely Mountain Dungeons忠告1:要学会计算时间复杂度!!
忠告2:要学会抓事实,不要掉进题目直观模拟的陷阱里
事实
1.任意k个数的
假设
那么可以通过移项变成
2.将n分成k个数的和,这k个数中的最小值
很显然啊,拿
3.根据事实12,当
于是我们可以
判断时间复杂度
最坏情况:
直接从
我们考虑优化
由于答案一定是
此时 最坏情况
#include<bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--) {
int n, k;
cin >> n >> k;
int result = 1;
for(int i = 1; i <= sqrt(n); i++) {
if(n % i == 0) {
if(i <= n / k) result = max(result, i);
if(n / i <= n / k) result = max(result, n / i);
}
}
cout << result << endl;
}
return 0;
}
合集:
codeforces
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具