题目链接:

C. Vectors

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

At a geometry lesson Gerald was given a task: to get vector B out of vector A. Besides, the teacher permitted him to perform the following operations with vector А:

  • Turn the vector by 90 degrees clockwise.
  • Add to the vector a certain vector C.

Operations could be performed in any order any number of times.

Can Gerald cope with the task?

Input

The first line contains integers x1 и y1 — the coordinates of the vector A ( - 108 ≤ x1, y1 ≤ 108). The second and the third line contain in the similar manner vectors B and C (their coordinates are integers; their absolute value does not exceed 108).

Output

Print "YES" (without the quotes) if it is possible to get vector B using the given operations. Otherwise print "NO" (without the quotes).

Examples
input
0 0
1 1
0 1
output
YES
input
0 0
1 1
1 1
output
YES
input
0 0
1 1
2 2
output
NO

题意:

两个操作,1把A向量旋转90度,2把C向量加到A向量上,现在两个操作可以执行任意多次,顺序也是任意的,问能否得到B向量;

思路:

假设D为C旋转90度的向量,E为A旋转后的向量;
可以发现最后得到的都是a*C+b*D=B-E;
这就变成了一个判断一个二元一次方程组是否有整数解的问题;
那么就判断好了; AC代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <stack>
#include <map> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
if(!p) { puts("0"); return; }
while(p) stk[++ tp] = p%10, p/=10;
while(tp) putchar(stk[tp--] + '0');
putchar('\n');
} const LL mod=1e9+7;
const double PI=acos(-1.0);
const LL inf=1e18;
const int N=(1<<20)+10;
const int maxn=1e6+10;
const double eps=1e-12; LL ax,ay,bx,by,cx,cy;
int solve(LL x,LL y)
{
x=bx-x;y=by-y;
if(cx==0&&cy==0)
{
if(x==0&&y==0)return 1;
return 0;
}
else if(cx==0)
{
LL g=x/cy,h=y/cy;
if(g*cy==x&&h*cy==y)return 1;
return 0;
}
else if(cy==0)
{
LL g=x/cx,h=y/cx;
if(g*cx==x&&h*cx==y)return 1;
return 0;
}
else
{
LL tx=x*cy,ty=y*cx;
LL b=(tx-ty)/(cy*cy+cx*cx);
if(b*(cx*cx+cy*cy)!=(tx-ty))return 0;
else
{
LL a=(x-b*cy)/cx;
if(a*cx+b*cy==x)return 1;
return 0;
}
}
}
int main()
{
read(ax);read(ay);
read(bx);read(by);
read(cx);read(cy);
int f=0;
if(solve(ax,ay))f=1;
if(solve(-ax,-ay))f=1;
if(solve(ay,-ax))f=1;
if(solve(-ay,ax))f=1;
if(f)cout<<"YES\n";
else cout<<"NO\n";
return 0;
}

  

codeforces 101C C. Vectors(数学)的更多相关文章

  1. CodeForces - 598C Nearest vectors(高精度几何 排序然后枚举)

    传送门: http://codeforces.com/problemset/problem/598/C Nearest vectors time limit per test 2 seconds me ...

  2. CodeForces 534C Polycarpus' Dice (数学)

    题意:第一行给两个数,n 和 A,n 表示有n 个骰子,A表示 n 个骰子掷出的数的和.第二行给出n个数,表示第n个骰子所能掷出的最大的数,这些骰子都有问题, 可能或多或少的掷不出几个数,输出n个骰子 ...

  3. codeforces 687B - Remainders Game 数学相关(互质中国剩余定理)

    题意:给你x%ci=bi(x未知),是否能确定x%k的值(k已知) ——数学相关知识: 首先:我们知道一些事情,对于k,假设有ci%k==0,那么一定能确定x%k的值,比如k=5和ci=20,知道x% ...

  4. Codeforces Gym 100269G Garage 数学

    Garage 题目连接: http://codeforces.com/gym/100269/attachments Description Wow! What a lucky day! Your co ...

  5. Codeforces C. Almost Equal (数学规律)

    题目链接:http://codeforces.com/contest/1206/problem/C 题解 : 观察可以发现当n为偶数时,1 - 2n是不满足题意的,可以举例n = 2,n = 4试一试 ...

  6. Educational Codeforces Round 15 D 数学推公式

    D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...

  7. CodeForces 589D Boulevard (数学,相遇)

    题意:给定 n 个的在 x 轴上的坐标,和开始时间,结束坐标,从起点向终点走,如果和其他人相遇,就互相打招乎,问你每人打招乎的次数. 析:其实这一个数学题,由于 n 比较小,我们就可以两两暴力,这两个 ...

  8. Codeforces 311D Interval Cubing 数学 + 线段树 (看题解)

    Interval Cubing 这种数学题谁顶得住啊. 因为 (3 ^ 48) % (mod - 1)为 1 , 所以48个一个循环节, 用线段树直接维护. #include<bits/stdc ...

  9. Codeforces 932E Team Work 数学

    Team Work 发现网上没有我这种写法.. i ^ k我们可以理解为对于每个子集我们k个for套在一起数有多少个. 那么我们问题就变成了 任意可重复位置的k个物品属于多少个子集. 然后我们枚举k个 ...

随机推荐

  1. 访问WEB-INFO 目录注意事项

    WEB-INF下面的内容都是只能由服务器级别才能访问,客户端并不能访问.什么是客户端级别?什么是服务器级别呢? 转发就是服务器级别,浏览器的地址不会变,因为,客户端发送一个请求,服务器受理之后,发现要 ...

  2. Mysql的简单使用(三)

    接上文Mysql的简单使用(二) mysql中结构相同的两个表进行合并:(注意需要两个表的结构是一样的) 有如下结构的两个表father和person. 合并的步骤为: 1.把person表和fath ...

  3. 轻量级SaaS在线作图工具ProcessOn

    俗话说“一图胜千言”,在办公应用领域,流程图是一个非常好的表现企业业务流程或工作岗位规范等内容的展现形式,比如去给客户做调研,回来后都要描述出客户的关键业务流程,谁.什么时候.在什么地方.负责什么事情 ...

  4. margin:0 auto;不能居中的原因

    原因: 1.没有设置本身元素和父元素的宽度 2.本身元素使用了绝对定位和浮动 2.没声明DOCTYPE

  5. .NET破解之轻量万能自定义信息管理系统

    一般敢说万能的莫非真有两把刷子.今天来破解试试,看效果好用不. 下载:http://down.chinaz.com/soft/36780.htm 补丁: http://www.t00y.com/fil ...

  6. C安全问题与指针误用

    欢迎关注我的个人博客:www.wuyudong.com, 更多精彩文章与您分享 指针的声明与初始化 1.不恰当的指针声明 考虑如下的声明: int* ptr1, ptr2; // ptr1为指针,pt ...

  7. IOS 实现 AAC格式 录音 录音后自动播放

    废话不说了 不知道aac可以百度一下 下面直接上代码,一个h文件 一个m文件 搞定! #import <AVFoundation/AVFoundation.h> #import <U ...

  8. OC语言-06-OC语言-block与protocol

    一.block 1> 基本使用 相当于用来存放代码的代码块 效率高 若没有形参可以省略小括号 2> block与函数的相同点 可以保存代码 可以有返回值 可以有形参 调用方式一样 3> ...

  9. 使用JDBC对数据库进行查询的前期准备工作,以及简单的JDBC访问MySQL数据库(Mac)

    首先JDBC的前期数据库数据准备: 1,打开链接好MySQL的Workbench软件,新建一个数据库: 2.然后打开数据库对应的代码编辑窗口,建立表和插入数据记录: 3.然后是打开关于javaWeb编 ...

  10. 每日Scrum--No.4

    Yesterday:学习迪杰斯特拉算法并进行简单的编写代码 Today:继续编写代码 Problem:变量名的定义出错,造成调用的时候出错,不过改过来就好了.算法的编写不全面,漏掉个别语句,如在调试的 ...