题意:求\((n-m)t+Lk=x-y\)的解\(t\)

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#define rep(i,j,k) for(register int i=j;i<=k;i++)
#define rrep(i,j,k) for(register int i=j;i>=k;i--)
#define erep(i,u) for(register int i=head[u];~i;i=nxt[i])
#define iin(a) scanf("%d",&a)
#define lin(a) scanf("%lld",&a)
#define din(a) scanf("%lf",&a)
#define s0(a) scanf("%s",a)
#define s1(a) scanf("%s",a+1)
#define print(a) printf("%lld",(ll)a)
#define enter putchar('\n')
#define blank putchar(' ')
#define println(a) printf("%lld\n",(ll)a)
#define IOS ios::sync_with_stdio(0)
using namespace std;
const int maxn = 1e6+11;
const int oo = 0x3f3f3f3f;
const double eps = 1e-7;
typedef long long ll;
ll read(){
ll x=0,f=1;register char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
ll exgcd(ll a,ll b,ll &x,ll &y){
if(b==0){
x=1;y=0;
return a;
}else{
ll gcd=exgcd(b,a%b,x,y);
ll tmp=x;
x=y;y=tmp-a/b*x;
return gcd;
}
}
int main(){
int kase=0;
ll x,y,m,n,L,MOD;
while(cin>>x>>y>>m>>n>>L){
ll t,k;
ll gcd=exgcd(n-m+L,L,t,k);
if((x-y+L)%gcd!=0) cout<<"Impossible"<<endl;
else{
t=t*(x-y+L)/gcd;
MOD=L/gcd;
t=(t%MOD+MOD)%MOD;
cout<<t<<endl;
}
}
return 0;
}

最新文章

  1. 10月24日下午PHP封装
  2. 整理BOM时写的关于拆分单元格的VB代码
  3. Java程序员的日常 —— 注册工厂的妙用
  4. VTK初学一,e_Triangle_CellArray三角形的另一种方法绘制
  5. BaseDao
  6. 1124. Mosaic(dfs)
  7. Java中线程顺序执行
  8. spring-data-redis --简单的用spring-data-redis
  9. mysql的limit性能,数据库索引问题,dblog问题
  10. Selenium八种基本定位方式---基于python
  11. nginx的概念与几种负载均衡算法
  12. Bi-shoe and Phi-shoe (欧拉函数)
  13. AndroidStudio制作“我”的界面,设置,修改密码,设置密保和找回密码
  14. 非const引用不能指向临时变量
  15. Selenium-Switch与SelectApi接口详解
  16. &lt;context:component-scan&gt;详解 转发 https://www.cnblogs.com/fightingcoding/p/component-scan.html
  17. Ubuntu清理系统垃圾 命令
  18. 一个C语言内存管理模块的实现
  19. iOS开发-DatePicker控件
  20. JVM总结篇

热门文章

  1. 2-chrome无法添加扩展程序
  2. Linux查看内存,负载状态
  3. _GNU_SOURCE宏
  4. Docker保存修改后的镜像
  5. Luogu 4069 [SDOI2016]游戏
  6. Python3 Scrapy + Selenium + 阿布云爬取拉钩网学习笔记
  7. SVN常见问题及解决方式(二)
  8. excel中的绝对引用和相对应用
  9. ASP.NET多页面传递数据,附框架源码
  10. canvas基本绘制图形