#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <stack>
#include <set>
#include <queue>
#define MAX(a,b) (a) > (b)? (a):(b)
#define MIN(a,b) (a) < (b)? (a):(b)
#define mem(a) memset(a,0,sizeof(a))
#define INF 1000000007
#define MAXN 20005
using namespace std; __int64 GCD(__int64 a,__int64 b)
{
return a%b==?b:GCD(b,a%b);
} void gcd(__int64 a,__int64 b,__int64 &x,__int64 &y)
{
if(!b){x=;y=;}
else{gcd(b,a%b,y,x); y-=x*(a/b);}
} int main()
{
__int64 X,Y,M,N,L;
while(~scanf("%I64d %I64d %I64d %I64d %I64d",&X,&Y,&M,&N,&L))
{
__int64 a = (N-M), b = L, c = (X-Y);
__int64 g = GCD(a,b);
if(c%g){ printf("Impossible\n"); continue;}
__int64 x, y;
gcd(a, b, x, y);
x*=(c/g);
if(x>)x%=(b/g);
else x=x%(b/g)+(b/g);
printf("%I64d\n",x);
}
return ;
}

最新文章

  1. 3D游戏编程大师技巧──2D引擎的编译问题
  2. [转]彻底征服 Spring AOP 之 实战篇
  3. 转载:Hadoop安装教程_单机/伪分布式配置_Hadoop2.6.0/Ubuntu14.04
  4. rabbitMQ学习(一)
  5. 在sublime中使用less
  6. Rhel6-mailsystem配置文档
  7. php截取字符串,无乱码
  8. 图解linux下top命令的使用
  9. SNMP配置和常用命令OID(转)
  10. 关于Asp.net超时,延长读取sql server数据库的超时时间!(已解决)
  11. LANMP一键安装包 版本服务任你选 可安装单一服务
  12. layui动态设置checkbox选中状态
  13. 怎样下载youtube的字幕
  14. 6M - 循环多少次?
  15. 记录:一个SQL SERVER奇怪的问题。
  16. 关于C++中的friend友元函数的总结
  17. curl以cookie的方式登录
  18. 学习计划 mysql 整数类型后面的数字,是什么意思?
  19. MySQL函数GROUP_CONCAT() 实现多条数据合并
  20. IOC给程序带来的好处

热门文章

  1. bzoj4080
  2. tomcat 默认项目设置
  3. LeetCode Swap Nodes in Pairs 交换结点对(单链表)
  4. 【转】linux驱动开发的经典书籍
  5. POJ 2159 Ancient Cipher
  6. MyBatis 入门到精通(三) 高级结果映射
  7. mybatis实战教程(mybatis in action)之九:mybatis 代码生成工具的使用
  8. TOAD FOR MYSQL 进行数据插入时乱码的解决办法---MariaDB 5.5
  9. &lt;转&gt;Python学习推荐
  10. 给Webkit内核的浏览器控件增加互交功能