【构造】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 ...
随机推荐
- 【ALB学习笔记】基于多线程方式的串行通信接口数据接收案例
基于多线程方式的串行通信接口数据接收案例 广东职业技术技术学院 欧浩源 1.案例背景 在本博客的<[CC2530入门教程-06]CC2530的ADC工作原理与应用>中实现了电压数据采集的 ...
- fileinput 小计(显示历史上传图片)
今天又需要,要求在选中某条记录后显示历史上传图片 上传控件是fileinput.js 想法:界面有上传图片的控件,重新加载控件,并加入历史上传图片地址 实现代码: var filepathArray ...
- spring-retry 重试机制
业务场景 应用中需要实现一个功能: 需要将数据上传到远程存储服务,同时在返回处理成功情况下做其他操作.这个功能不复杂,分为两个步骤:第一步调用远程的Rest服务逻辑包装给处理方法返回处理结果:第二步拿 ...
- mysql in/no in/like
% 任意字符 _ 任意一个字符 in (value,......) 在这里 not in (value,......) 不在这里 mysql> select 'a' not in (1,2,3, ...
- Mojo_1_第一个简单例子
use Mojolicious::Lite; #根目录,Get方法打开 #正接显示文本text get '/' => sub{ my $service = shift; $service-> ...
- CTF线下赛AWD模式下的生存技巧
作者:Veneno@Nu1L 稿费:200RMB 投稿方式:发送邮件至linwei#360.cn,或登陆网页版在线投稿 原文:https://www.anquanke.com/post/id/8467 ...
- python基础===单元测试unittest
''' 编写一个名为Employee 的类,其方法__init__()接受名.姓和年薪,并 将它们都存储在属性中.编写一个名为give_raise()的方法,它默认将年薪增加5000 美元,但也能够接 ...
- 可以高度定制的代理服务器anyproxy
简介 anyproxy是一款可以高度定制的代理服务器,基于nodejs. 特征 支持https明文代理 支持低网速模拟 支持二次开发,可以用javascript控制代理的全部流程,搭建前端个性化调试环 ...
- [ python ] 类的组合
首先,使用面向对象是一个人狗大战的实例: class Person: def __init__(self, name, hp, aggr, sex): self.name = name self.hp ...
- [PAT] 1143 Lowest Common Ancestor(30 分)1145 Hashing - Average Search Time(25 分)
1145 Hashing - Average Search Time(25 分)The task of this problem is simple: insert a sequence of dis ...