Codeforces #24 C. Sequence of points

针对一个平面几何问题,通过寻找序列点Mj的规律来解决输入坐标后的大规模索引查询问题。该问题中,一系列点Mi根据特定规则对称变换生成,目标是找出任意指定索引j对应的点Mj坐标。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

C. Sequence of points
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given the following points with integer coordinates on the plane:M0, A0, A1, ..., An - 1, wheren is odd number. Now we define the following infinite sequence of pointsMi:Mi is symmetric toMi - 1 according (for every natural numberi). Here point B is symmetric toA according M, ifM is the center of the line segment AB. Given index j find the pointMj.

Input

On the first line you will be given an integer n (1 ≤ n ≤ 105), which will be odd, andj (1 ≤ j ≤ 1018), wherej is the index of the desired point. The next line contains two space separated integers, the coordinates ofM0. After thatn lines follow, where the i-th line contain the space separated integer coordinates of the pointAi - 1. The absolute values of all input coordinates will not be greater then1000.

Output

On a single line output the coordinates of Mj, space separated.

Sample test(s)
Input
3 4
0 0
1 1
2 3
-5 3
Output
14 0
Input
3 1
5 5
1000 1000
-1000 1000
3 100
Output
1995 1995

小伙伴为了明天的轻工校赛而找的比赛题目,一共三题,难度好像都不小啊。。。
这个题题意比较难理解,就是给出n,j;之后再给出m[0]的坐标,a[0]-a[n-1]的坐标
让你输出m[j]的坐标,其中m[i]和m[i-1]关于a[(i-1)%n]对称
因为j最大为10的18次方,所以想到找规律。。。
我就把两个样例的m[1]-m[6]都列出来,结果发现m[6]和m[1]重合了!!!
就是说m[i%(2*n)]==m[i]

代码如下:
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define esp 1e-9
#define MAXN 200010
#define ll long long
#define INF 0x7FFFFFFF
#define BUG system("pause")
#define SW(a,b) a^=b;b^=a;a^=b;
using namespace std;
struct Point{
	int x, y;
}m[MAXN], a[MAXN];
int main(void){
	int n;
	ll  j;
	while(cin >> n >> j) {
		cin >> m[0].x >> m[0].y;
		for(int i=0; i<n; ++i){
			cin >> a[i].x >> a[i].y;
		}
		for(int i=0; i<2*n; ++i){
			m[i+1].x = 2*a[i%n].x-m[i].x;
			m[i+1].y = 2*a[i%n].y-m[i].y;
			cout << "m[" << i+1 << "]:x = " << m[i+1].x << " y = " << m[i+1].y << endl;
		}
		cout << m[j%(2*n)].x << " " << m[j%(2*n)].y << endl;
	} 

	return 0;
}


内容概要:本文详细介绍了施耐德M580系列PLC的存储结构、系统硬件架构、上电写入程序及CPU冗余特性。在存储结构方面,涵盖拓扑寻址、Device DDT远程寻址以及寄存器寻址三种方式,详细解释了不同类型的寻址方法及其应用场景。系统硬件架构部分,阐述了最小系统的构建要素,包括CPU、机架和模块的选择与配置,并介绍了常见的系统拓扑结构,如简单的机架间拓扑和远程子站以太网菊花链等。上电写入程序环节,说明了通过USB和以太网两种接口进行程序下载的具体步骤,特别是针对初次下载时IP地址的设置方法。最后,CPU冗余部分重点描述了热备功能的实现机制,包括IP通讯地址配置和热备拓扑结构。 适合人群:从事工业自动化领域工作的技术人员,特别是对PLC编程及系统集成有一定了解的工程师。 使用场景及目标:①帮助工程师理解施耐德M580系列PLC的寻址机制,以便更好地进行模块配置和编程;②指导工程师完成最小系统的搭建,优化系统拓扑结构的设计;③提供详细的上电写入程序指南,确保程序下载顺利进行;④解释CPU冗余的实现方式,提高系统的稳定性和可靠性。 其他说明:文中还涉及一些特殊模块的功能介绍,如定时器事件和Modbus串口通讯模块,这些内容有助于用户深入了解M580系列PLC的高级应用。此外,附录部分提供了远程子站和热备冗余系统的实物图片,便于用户直观理解相关概念。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值