【构造】Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals) B. High Load
让你构造一棵树(给定了总结点数和总的叶子数),使得直径最小。
就先弄个菊花图(周围一圈叶子,中间一个点),然后平均地往那一圈放其他的点即可。
#include<cstdio>
using namespace std;
int n,K,Ks[200010],x[200010],y[200010],ans,e;
int main(){
scanf("%d%d",&n,&K);
for(int i=1;i<=K;++i){
Ks[i]=1;
}
int now=2;
for(;;){
for(int i=1;i<=K;++i,++now){
if(now>n){
goto OUT;
}
x[++e]=Ks[i];
y[e]=now;
Ks[i]=now;
if(i==1){
++ans;
}
else if(i==2){
++ans;
}
}
}
OUT:
printf("%d\n",ans);
for(int i=1;i<=e;++i){
printf("%d %d\n",x[i],y[i]);
}
return 0;
}
【构造】Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals) B. High Load的更多相关文章
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) D. High Load 构造
D. High Load 题目连接: http://codeforces.com/contest/828/problem/D Description Arkady needs your help ag ...
- Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals)
Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals) A.String Reconstruction B. High Load C ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) E. DNA Evolution 树状数组
E. DNA Evolution 题目连接: http://codeforces.com/contest/828/problem/E Description Everyone knows that D ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) Problem E (Codeforces 828E) - 分块
Everyone knows that DNA strands consist of nucleotides. There are four types of nucleotides: "A ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) D 构造烟花
D. High Load time limit per test 2 seconds memory limit per test 512 megabytes input standard input ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals)
题目链接:http://codeforces.com/contest/828 A. Restaurant Tables time limit per test 1 second memory limi ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) C. String Reconstruction 并查集
C. String Reconstruction 题目连接: http://codeforces.com/contest/828/problem/C Description Ivan had stri ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) A,B,C
A.题目链接:http://codeforces.com/contest/828/problem/A 解题思路: 直接暴力模拟 #include<bits/stdc++.h> using ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 828D) - 贪心
Arkady needs your help again! This time he decided to build his own high-speed Internet exchange poi ...
随机推荐
- canvas利用formdata上传到服务器
1.首先绘制canvas图片 <canvas id="myCanvas" width="100" height="100" style ...
- 刷新SqlServer数据库中所有的视图
ALTER PROCEDURE sp_refallview AS --刷新所有视图 DECLARE @ViewName VARCHAR(MAX); DECLARE @i INT; ; DECLARE ...
- python按比例随机切分数据
在机器学习或者深度学习中,我们常常碰到一个问题是数据集的切分.比如在一个比赛中,举办方给我们的只是一个带标注的训练集和不带标注的测试集.其中训练集是用于训练,而测试集用于已训练模型上跑出一个结果,然后 ...
- freemark学习
学习地址: http://blog.csdn.net/hejinxu/article/details/6694890 对freemarker的用法与语法进行了详细的讲解 http://freema ...
- English——Unit 2
radiant radiate radical ideal ideology identical identification identify identity journal jounalist ...
- 使用 Visual Studio 部署 .NET Core 应用
可将 .NET Core 应用程序部署为依赖框架的部署或独立部署,前者包含应用程序二进制文件,但依赖目标系统上存在的 .NET Core,而后者同时包含应用程序和 .NET Core 二进制文件. 有 ...
- Can't load standard profile: GRAY.pf
报错: java.lang.IllegalArgumentException: Can't load standard profile: GRAY.pf at java.awt.color.ICC_P ...
- Python 微信公众号发送消息
1. 公众号测试地址 https://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index 2. ...
- 机器学习方法(六):随机森林Random Forest,bagging
欢迎转载,转载请注明:本文出自Bin的专栏blog.csdn.net/xbinworld. 技术交流QQ群:433250724,欢迎对算法.技术感兴趣的同学加入. 前面机器学习方法(四)决策树讲了经典 ...
- AC日记——[SCOI2009]游戏 bzoj 1025
[SCOI2009]游戏 思路: 和为n的几个数最小公倍数有多少种. dp即可: 代码: #include <bits/stdc++.h> using namespace std; #de ...