CodeForces 787A The Monster
来源:互联网 发布:胡歌顶级时尚资源知乎 编辑:程序博客网 时间:2024/06/05 04:39
题目链接:http://codeforces.com/contest/787/problem/A
题意:有两个序列,一个是由b+a*x组成,一个是由d+c*y组成,问你他们第一个相等的是哪个
解析:直接暴力枚举了x,然后去判断y是否存在
#include <iostream>#include <cstdio>#include <algorithm>#include <vector>#include <cstring>#include <queue>#include <cmath>#include <map>using namespace std;const int maxn = 1e6+100;const int inf = 0x7fffffff;const int mod = 1e9;int main(void){ int a,b,c,d; scanf("%d %d %d %d",&a,&b,&c,&d); int flag = 1; for(int i=0;i<maxn;i++) { int t1 = b+a*i; if((t1-d)%c==0 && t1>=d) { flag = 0; printf("%d\n",t1); break; } } if(flag) puts("-1"); return 0;}
0 0
- CodeForces 787A The Monster
- CodeForces 787A A. The Monster(扩展欧几里得)
- codeforces 787A The Monster (猜想 + 证明)
- codeforces 787A The Monster 扩展欧几里德 Java
- codeforces 487A Fight the Monster
- 【Codeforces】 487A Fight the Monster
- CodeForces 487A Fight the Monster
- codeforces #487A# Fight the Monster(枚举)
- Codeforces 487A Fight the Monster(暴力)
- Codeforces 487A Fight the Monster
- CodeFroces 787A The Monster
- codeforce 787 A. The Monster
- The Monster (Codefores-787A)
- codeforces 787A the monster(扩展欧几里得做法+暴力做法)
- codeforces 487 A Fight the Monster 暴力枚举
- A. The Monster
- Cf 406 A. The Monster
- codeforces B. The Monster and the Squirrel
- 脑图和目录的区别
- 优化 | MySQL全面快速优化参考
- Spring-9 , 使用外部属性文件
- NYOJ1294 刚哥遇到了感情问题(二)(字符串处理)
- 程序编译,链接过程
- CodeForces 787A The Monster
- css中的z-index(一)
- 在linux服务器上搭建相对安全的FTP服务器
- 用宏写一个函数交换一个数的奇偶位 并简析宏与函数调用
- java中什么是线程安全给出一个例子
- git分支管理
- Hadoop学习笔记—1.初识hadoop
- 进程之间的通信方式-共享内存
- MySQL优化案例