题目链接:

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
  1. 0 0
    1 1
    0 1
output
  1. YES
input
  1. 0 0
    1 1
    1 1
output
  1. YES
input
  1. 0 0
    1 1
    2 2
output
  1. NO
  2.  
  3. 题意:
  4.  
  5. 两个操作,1A向量旋转90度,2C向量加到A向量上,现在两个操作可以执行任意多次,顺序也是任意的,问能否得到B向量;
  6.  
  7. 思路:
  8.  
  9. 假设DC旋转90度的向量,EA旋转后的向量;
    可以发现最后得到的都是a*C+b*D=B-E;
    这就变成了一个判断一个二元一次方程组是否有整数解的问题;
    那么就判断好了;
  10.  
  11. AC代码:
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <bits/stdc++.h>
  7. #include <stack>
  8. #include <map>
  9.  
  10. using namespace std;
  11.  
  12. #define For(i,j,n) for(int i=j;i<=n;i++)
  13. #define mst(ss,b) memset(ss,b,sizeof(ss));
  14.  
  15. typedef long long LL;
  16.  
  17. template<class T> void read(T&num) {
  18. char CH; bool F=false;
  19. for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
  20. for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
  21. F && (num=-num);
  22. }
  23. int stk[70], tp;
  24. template<class T> inline void print(T p) {
  25. if(!p) { puts("0"); return; }
  26. while(p) stk[++ tp] = p%10, p/=10;
  27. while(tp) putchar(stk[tp--] + '0');
  28. putchar('\n');
  29. }
  30.  
  31. const LL mod=1e9+7;
  32. const double PI=acos(-1.0);
  33. const LL inf=1e18;
  34. const int N=(1<<20)+10;
  35. const int maxn=1e6+10;
  36. const double eps=1e-12;
  37.  
  38. LL ax,ay,bx,by,cx,cy;
  39. int solve(LL x,LL y)
  40. {
  41. x=bx-x;y=by-y;
  42. if(cx==0&&cy==0)
  43. {
  44. if(x==0&&y==0)return 1;
  45. return 0;
  46. }
  47. else if(cx==0)
  48. {
  49. LL g=x/cy,h=y/cy;
  50. if(g*cy==x&&h*cy==y)return 1;
  51. return 0;
  52. }
  53. else if(cy==0)
  54. {
  55. LL g=x/cx,h=y/cx;
  56. if(g*cx==x&&h*cx==y)return 1;
  57. return 0;
  58. }
  59. else
  60. {
  61. LL tx=x*cy,ty=y*cx;
  62. LL b=(tx-ty)/(cy*cy+cx*cx);
  63. if(b*(cx*cx+cy*cy)!=(tx-ty))return 0;
  64. else
  65. {
  66. LL a=(x-b*cy)/cx;
  67. if(a*cx+b*cy==x)return 1;
  68. return 0;
  69. }
  70. }
  71. }
  72. int main()
  73. {
  74. read(ax);read(ay);
  75. read(bx);read(by);
  76. read(cx);read(cy);
  77. int f=0;
  78. if(solve(ax,ay))f=1;
  79. if(solve(-ax,-ay))f=1;
  80. if(solve(ay,-ax))f=1;
  81. if(solve(-ay,ax))f=1;
  82. if(f)cout<<"YES\n";
  83. else cout<<"NO\n";
  84. return 0;
  85. }

  

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. HTTP路由

    HTTP路由 HTTP路由(译者注:Play的路径映射机制)组件负责将HTTP请求交给对应的action(一个控制器Controller的公共静态方法)处理. 对于MVC框架来说,一个HTTP请求可以 ...

  2. iphone 使用 soap 服务 介绍

    iphone 使用 soap 服务 介绍 目前比较常用的有几个办法: 1. WSDL to Objective C自动根据wsdl文件生成ios可以直接调用的Objective-C (Cocoa) 代 ...

  3. html与js的取值,赋值

    -------------------------------------------------- ------------------------------------------------- ...

  4. andriod 动态显示当前时间

    <?xml version="1.0" encoding="UTF-8"?> <LinearLayout xmlns:android=&quo ...

  5. SharePoint 2013 中自定义WCF服务

    在使用SharePoint2013的时候,如果其他客户端 API 的组合不足,可以通过自定义 Web 服务扩展 SharePoint.默认情况下,SharePoint 2013 不仅支持创建自定义 A ...

  6. sharepoint 2013 文件“/_controltemplates/SPMRB/AllStatBookingsForm.ascx”不存在

    现象: 文件“/_controltemplates/SPMRB/AllStatBookingsForm.ascx”不存在. 分析: 此代码在sp2010好用,但是在sp2013则报以上错误. 解决办法 ...

  7. Android项目实战(七):Dialog主题Activity实现自定义对话框效果

    想必大家都用过Dialog主题的Activity吧,用它来显示自定义对话框效果绝对是一个非常不错的选择. 即把activity交互界面以Dialog的形式展现出来,Dialog主题的Activity大 ...

  8. Android—SQLITE数据库的设计和升降级

    Google为Andriod的较大的数据处理提供了SQLite,他在数据存储.管理.维护等各方面都相当出色,功能也非常的强大.SQLite具备下列特点: 1.轻量级 使用 SQLite 只需要带一个动 ...

  9. IOS真机测试(用证书进行真机测试)

    真机测试需要准备 1.证书 2.Iphone或者Ipad 3.到developer.apple.com注册开发者账号(不用money的) ------------------------------- ...

  10. Spring(四)Bean注入方试

    一.构造方法注入 定义:通过构造函数来完成依赖关系的设定 优缺点: 在构造对象的同时,完成依赖关系的建立 如果关联的对象很多,那和不得不在构造方法上加入过多的参数 基中有index:如果指定索引从0开 ...