codeforces 8VC Venture Cup 2017 - Elimination Round D PolandBall and Polygon

科技中介服务机构想要提升服务效率,需要哪些数智工具支持?.docx 科技中介服务机构想要提升服务效率,需要哪些数智工具支持? 立即下载

D. PolandBall and Polygon
time limit per test
4 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.

He chose a number k such that gcd(n, k) = 1. Vertices of the polygon are numbered from 1 to n in a clockwise way. PolandBall repeats the following process n times, starting from the vertex 1:

Assume you've ended last operation in vertex x (consider x = 1 if it is the first operation). Draw a new segment from vertex x to k-th next vertex in clockwise direction. This is a vertexx + k or x + k - n depending on which of these is a valid index of polygon's vertex.

Your task is to calculate number of polygon's sections after each drawing. A section is a clear area inside the polygon bounded with drawn diagonals or the polygon's sides.

Input

There are only two numbers in the input: n and k (5 ≤ n ≤ 106, 2 ≤ k ≤ n - 2, gcd(n, k) = 1).

Output

You should print n values separated by spaces. The i-th value should represent number of polygon's sections after drawing first i lines.

Examples
input
5 2
output
2 3 5 8 11 
input
10 3
output
2 3 4 6 9 12 16 21 26 31 
Note

The greatest common divisor (gcd) of two integers a and b is the largest positive integer that divides both a and b without a remainder.

For the first sample testcase, you should output "2 3 5 8 11". Pictures below correspond to situations after drawing lines.

题意如图,因为保证了gcd(n,k)==1,所以肯定不会出现重边的情况,所以每次增加的区域个数,其实也就是这条线起点终点两点之间的所有点上的已有的边之和再加一,

例如这一次起点是1,终点是3,增加的区域数也就是2顶点上连的边个数加一,直接暴力求之间所有边的和肯定会t,所以用树状数组维护,模拟求和


但最后wa在了test6上。。。


没想出来为什么,看了题解,发现好智障

当k>n/2时,起点和终点的跨过区域就是反向的,令k=n-k即可(可以联想一下圆,扇形圆心角大于180度时候的情况)

#include<stdio.h>
int bit[1000006],n,k;
int sum(int i)
{
	int s=0;
	while(i>0)
	{
		s+=bit[i];
		i-=i&-i;
	}
	return s;
}
void add(int i,int x)
{
	while(i<=n)
	{
		bit[i]+=x;
		i+=i&-i;
	}
	return ;
}
int main()
{
	int x,be,ne,j,i;
	long long int ans;
	scanf("%d %d",&n,&k);
	if(k>(n/2))
	k=n-k;
	j=n;
	be=1;
	ans=1;
	while(j--)
	{
		ne=be+k;
		if(ne>n)
		{
			ne-=n;
			ans+=(sum(n)-sum(be));
			ans+=sum(ne-1);
			ans++;	
		}
		else
		{
			ans+=(sum(ne-1)-sum(be)+1);
		}
		add(be,1);
		add(ne,1);
		be=ne;
		printf("%lld ",ans);
	}
	printf("\n");
	return 0;
}


usb 扩容盘检测修复工具源码,编译产物 立即下载

相关推荐

利用随机矩阵理论(random matrix theory)确定微生物网络构建阈值

利用随机矩阵理论(random matrix theory)确定微生物网络构建阈值

微生物生态学分析 7639

Codeforces 8VC Venture Cup 2017 - Elimination Round D.PolandBall and Polygon

传送门:PolandBall and Polygon 题意:给定n条边的凸多边形,保证这种凸多边形任意三条对角线不会交于一点,然后从一顶点出发,每次走K步,然后将出发点与终点连接起来,输出此时多边形被分成的块数,重复此步骤n次。 解法:个人感觉就是多画几个图找规律。。或者你的几何学的好能推出公式或规律来,我发现的规律就是每画一条对角线,增加的块数等于该对角线跨过的对角线条数+1,也等于走的K步

WA是一笔财富 689

Matlab图像处理频域滤波实现——高斯低通、高通、带通带阻滤波器

如果你想要进一步了解更多的相关知识,

小嘤熊的博客 1万+

8VC Venture Cup 2017 - Elimination Round D. PolandBall and Polygon 树状数组

D. PolandBall and Polygon 链接: http://codeforces.com/contest/755/problem/D 代码: 1 #include &lt;iostream&gt; 2 #include &lt;cstdio&gt; 3 #include &lt;cstring&gt; 4 #include &lt;cmath&gt...

花海 131

Box2D-Lite源码阅读笔记(2)

0.初始化函数 static void InitDemo(int index) { world.Clear(); numBodies = 0; numJoints = 0; bomb = NULL; demoIndex = index; demos[index](bodies, joints); } 在这个初始化函数中,一般会默认执行index=0的函数,这个函数就是一个示例,因为示例比较简单,所以也便于研究,示例效果如下。 就是一个方块。 进入第一个示例函数。(忽略我加的注释)

ARTELE的博客 976

LIN协议栈 AUTOSAR架构下 状态管理

LIN State Manager 通过对这些状态的管理和转换,实现了对 LIN 总线通信状态的精确控制,以满足汽车电子系统中不同场景的需求。

汽车电子从业者,电子爱好者。 2052

Codeforces Round #382 (Div. 2)A到D题 A. Ostap and //B. Urbanization//C. Tennis Championship//D. Taxes

A. Ostap and Grasshopper time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output On the way to Rio de Janeiro Ostap

jerans的博客 1287

ESP-01S获取网络时间踩坑全记录:AT指令调试、JSON解析乱码、时区处理,一个都不能少

本文详细记录了使用ESP-01S WIFI模块获取网络时间的完整过程,包括AT指令调试、JSON解析乱码处理以及时区转换等关键步骤。通过实战案例和代码示例,帮助开发者避开常见陷阱,实现稳定的网络时间同步功能。

weixin_30460489的博客 295

Gym - 101128C Canvas Painting 逆向思维

https://odzkskevi.qnssl.com/3699857ff0a17d77d1099699cdf4da13?v=1490503337 刚开始读错题意,以为是不变序列,就想着区间dp但数据量肯定会t,,,没想到什么优化方法就放下了,后来队员发现序列是可变的。。。。任意的。。。。。 想着先排序在布拉布拉布拉,一直都没有逆向思维想到哈夫曼。只怪数据结构没认真听啊。。。。 想到哈夫

jerans的博客 945

mongoDB 数据莫名其妙的没了

问题 之前没有接触过mongoDB,然后接手一个项目使用的是MongoDB,我就跟着网上的教程搭建一个MongoDB的服务,并运行起来。 一开始没有啥问题,成功的把服务与MongoDB都启动以来,运行也没有问题。但是过了几天,我再次打开时发现,以前的数据神奇的消失了。我还在想,是有什么定时清除的么,还是什么原因导致崩了然后数据就被清理了。 查找原因 第一次遇到我没有在意,重启了一下MongoDB,...

技术熊的博客小窝 1万+

笔试题-2023-紫光展锐-数字芯片设计【纯净题目版】

笔试题-2023-紫光展锐-数字芯片设计【纯净题目版】

w0shishabi的博客 2923

CodeForces - 361D Levko and Array二分加dp

D. Levko and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Levko has an array that consists of inte

jerans的博客 840

国科大学习资料--图像处理(彭思龙、杨戈)--2020年期末考试题解析(学长整理分析)

在对20年卷子分析前,先看看19年卷子的解析(后面有20年的变化,由于从核心课调整到了普及课,20年的卷子相对简单,但是还是有很多细节) 解析:(字写的不好别嫌弃!!!!) 20年的卷子 第一题:和19年基本一致,但是加了高斯核计算费用,要算一个节省计算成本比率,所以去多看看PPT 第二题:和19年基本一致,加了证明两个高斯卷积仍然是高斯卷积,相当于19年题2和3结合 第三题:采样定理,和19年基本一致,但要注意加了证明 第四题:考了形态学提取图像边界 第五题:直方图,和19年一

无名何许人的博客 4364

Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C Fountains 乱搞

C. Fountains time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Arkady plays Gardenscapes a lot. Arkady wants

jerans的博客 810

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

B. The Meeting Place Cannot Be Changed

B. The Meeting Place Cannot Be Changed time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output The main road in Byt

jerans的博客 695

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

Codeforces Round #380 (Div. 2,Based on Technocup 2017 - Elimination Round 2)C - Road to Cine//

C. Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya is currently at a car rental service

jerans的博客 684

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Beautiful numbers CodeForces - 55D 数位dp

D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Volodya is an odd boy and his taste is

jerans的博客 676

Codeforces Round #423 (Div. 2) C. String Reconstruction思维 D. High Load 构造

C:http://codeforces.com/contest/828/problem/C 题意:有一个字符串,你知道他的一些子串所在的位置,求符合条件的字典序最小的原串 因为已知的数据较大,还存在较多重复的部分,直接暴力不可行 可以记录原串每个位置的下一个没确定出来的字符的位置(记住next【i】),优化后可以过,时间较长 #include #define eps 1e-9 #defin

jerans的博客 672

Codeforces Round #410 (Div. 2) C. Mike and gcd problem 贪心

C. Mike and gcd problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a sequence A = [a1, a2, ..

jerans的博客 662

Codeforces Round #301 (Div. 2) D. Bad Luck Island 概率dp

D. Bad Luck Island time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Bad Luck Island is inhabited by thre

jerans的博客 648

Codeforces Round #424 (Div. 2)C. Jury Marks 暴力 D. Office Keys 二分 E. Cards Sorting 树状数组

C:http://codeforces.com/contest/831/problem/C。 题意:给两个序列a和b 有一个初始值,不断的加ai,要求是在加的过程中b的所有值都出现过,求这样满足条件的初始值有几个。 崩了,这么水的暴力竟然没想出来?? 先把所有的b值标记出来,随便选一个b,暴力放到某一个a后面,这样就可以直接找出原序列,看看b数组里的值是不是都出现过,如果出现过则这个序列满

jerans的博客 632

Codeforces Round #433(Div. 1,based on Olympiad of Metropolises)A Planning B Jury Meeting C Boredom

人生的第一次div.1 掉分 QAQ A - Planning http://codeforces.com/contest/853/problem/A 贪心,排个序,优先安排花费大的,用模拟链表实现的 #include #define eps 1e-9 #define PI 3.141592653589793 #define bs 1000000007 #define bsize

jerans的博客 626

Codeforces Round #410 (Div. 2) D. Mike and distribution 思维

D. Mike and distribution time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has always been thinking abou

jerans的博客 608

Codeforces Round #390 (Div. 2//754D. Fedor and coupons

D. Fedor and coupons time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output All our characters have hobbies. The s

jerans的博客 581
上一篇: Codeforces Round #390 (Div. 2//754D. Fedor and coupons
下一篇: HDU-3555Bomb 数位dp
jerans
博客等级 码龄10年 54粉丝 255原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值