题目链接: 点击我打开链接

题目大意:

给你 \(n,j\),再给出 \(m[0]\) 的坐标和\(a[0]-a[n-1]\) 的坐标。

让你输出 \(m[j]\) 的坐标,其中 \(m[i]\) 和 \(m[i-1]\) 关于 \(a[(i-1)\%n]\) 对称。

简明题解:

\(j\) 最大为\(10^{18}\) ,所以只能打表找规律了。

把两个样例(即\(n==3\)时)的 \(m[1]-m[9]\) 都列出来,结果发现 \(m[0]和m[6],m[1]和m[7]...\)是相等的.

就是说 \(m[j\%(2*n)]==m[j]\).

打表代码:

#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
#pragma G++ optimize ("O3")
typedef long long ll;
const int maxn = 567890;
const int lowbit(int x) { return x&-x; }
int read(){ int v = 0, f = 1;char c =getchar();
while( c < 48 || 57 < c ){if(c=='-') f = -1;c = getchar();}
while(48 <= c && c <= 57) v = v*10+c-48, c = getchar();
return v*f;} struct point
{
int x,y;
}m[123456],a[123456];
int main()
{
int n; ll j;
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=1;i<=3*n;i++)
{
m[i].x=(2*a[(i-1)%n].x-m[i-1].x);
m[i].y=(2*a[(i-1)%n].y-m[i-1].y);
}
for(int i=0;i<=3*n;i++)
{
cout<<"m["<<i<<"]"<<" "<<"x="<<m[i].x<<" "<<"y="<<m[i].y<<endl;
}
return 0;
}

\(AC\) 代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
pair< pair<int,int>, int> pii[123456]; struct point
{
int x,y;
}m[123456],a[123456];
int main()
{
int n; ll j;
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[j%(2*n)].x<<" ";
cout<<m[j%(2*n)].y<<endl;
return 0;
}

Codeforces Beta Round #24 D. Broken robot (打表找规律)的更多相关文章

  1. Codeforces Beta Round #51 C. Pie or die 博弈论找规律 有趣的题~

    C. Pie or die Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/problem/ ...

  2. codeforces#1159D. The minimal unique substring(打表找规律+构造)

    题目链接: https://codeforces.com/contest/1159/problem/D 题意: 构造一个长度为$n$的$01$串,最小特殊连续字串的长度为$k$ 也就是,存在最小的$k ...

  3. Codeforces 1392H - ZS Shuffles Cards(DP+打表找规律)

    Codeforces 题面传送门 & 洛谷题面传送门 真·两天前刚做过这场的 I 题,今天模拟赛就考了这场的 H 题,我怕不是预言带师 提供一种奇怪的做法,来自于同机房神仙们,该做法不需要 M ...

  4. Codeforces Beta Round #13 C. Sequence (DP)

    题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...

  5. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  6. Codeforces Beta Round #62 题解【ABCD】

    Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...

  7. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  8. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  9. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

随机推荐

  1. CodeForcesGym 100502G Outing

    Outing Time Limit: 1000ms Memory Limit: 524288KB This problem will be judged on CodeForcesGym. Origi ...

  2. Android.mk脚本推断文件是否存在

    Android.mk 推断文件是否存在,若存在则复制该文件到某个文件夹 $(shell test -f [文件] && echo yes)的值假设是yes, 则文件存在,然后进行she ...

  3. OcadeToolkit - From 2D CAD to PDMS

    OcadeToolkit - From 2D CAD to PDMS eryar@163.com Abstract. 基于开源二维CAD软件QCAD开发的插件可以将DXF文件中直线.圆弧转换到PDMS ...

  4. mysql异常Lock wait timeout exceeded; try restarting transaction

    mysql中使用update语句更新数据报错: Lock wait timeout exceeded; try restarting transaction. 这是由于你要更新的表的锁在其它线程手里. ...

  5. SpringJunit测试类 BaseTest(转)

    /** * * * @author Jerval * @date 2011-2-17 */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfig ...

  6. Resource Access Based on Multiple Credentials

    A collection of multiple user credentials each associated with one of multiple different users is ob ...

  7. PA模块经常使用表

    SELECT * FROM pa_projects_all; --项目 SELECT * FROM pa_project_types; --项目类型 SELECT * FROM pa_project_ ...

  8. 算法导论——lec 12 平摊分析与优先队列

    在平摊分析中,运行一系列数据结构操作所须要的时间是通过对运行的全部操作求平均得出.反映在不论什么情况下(即最坏情况下),每一个操作具有平均性能.掌握了平摊分析主要有三种方法,聚集分析.记账方法.势能方 ...

  9. jquery js解析函数、函数直接调用

    ----------------------------------------------------------------- cc = function(){alert(345)}, pushS ...

  10. php中类文件名的命名的规则是什么

    php中类文件名的命名的规则是什么 一.总结 一句话总结:类库文件(工具类)类文件都是以.class.php为后缀. 1.类的方法和属性的命名规则是怎样的? 都是小驼峰法 方法的命名使用驼峰法,并且首 ...