#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <math.h>
#include <queue>
#include <stack>
using namespace std;
#define INF 0x3f3f3f
#define pi acos(-1.0)
#define LL long long
LL exgcd(LL a,LL b,LL &x,LL &y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
LL ans=exgcd(b,a%b,x,y);
LL temp=x;
x=y;
y=temp-a/b*y;
return ans;
}
int main()
{
LL v1,v2;
LL m;
LL s1,s2;
LL a,b,x,y,v,c;
scanf("%lld%lld%lld%lld%lld",&s1,&s2,&v1,&v2,&m);
c=s2-s1;
a=v1-v2;//-1
b=m; //6
if(a<0)
a+=m;
LL d;
d=exgcd(a,b,x,y);
if(c%d||s1==s2)
{
printf("-1\n");
return 0;
}
a=a/d;
b=b/d;
c=c/d;
//printf("%lld\n",c);
x=x*c%b;
while(x<0)
x+=b;
printf("%lld\n",x);
return 0;
}
相关文章
- 03-28STM32学习和实践笔记(20):定时器-1.定时器介绍 STM32F1的定时器一共有8个,由2个基本定时器(TIMTIM7)、4个通用定时器(TIM2-TIM5)和2个高级定时器(TIMTIM8)组成。 基本定时器的功能最为简单,类似于51单片机内定时器。 通用定时器是在基本定时器的基础上扩展而来,增加了输入捕获与输出比较等功能。重点讲这种。 高级定时器又是在通用定时器基础上扩展而来,增加了可编程死区互补输出、重复计数器、带刹车(断路)功能,这些功能主要针对工业电机控制方面,一般情况下很少使用。 1.1 通用定时器简介 STM32F1的通用定时器包含一个 16 位自动重载计数器(CNT),该计数器由可编程预分频器(PSC)驱动。 STM32F1的通用定时器可用于多种用途,包括测量输入信号的脉冲宽度(输入捕获)或者生成输出波形(输出比较和PWM)等。 使用定时器预分频器和 RCC 时钟控制器预分频器,脉冲长度和波形周期可以在几个微秒到几个毫秒间调整。 STM32F1 的每个通用定时器都是完全独立的,没有互相共享的任何资源。 STM32F1的通用定时器TIMx (TIM2-TIM5 )具有如下功能:
- 03-28如何配置Postgres的自动扩展功能以应对数据增长-示例代码
- 03-28北大&字节联合发布视觉自动回归建模(VAR):通过下一代预测生成可扩展的图像
- 03-28Kafka的基本介绍以及扩展
- 03-28Apache Kafka的伸缩性探究:实现高性能、弹性扩展的关键
- 03-28ES9学习 -- 对象的剩余参数与扩展运算符 / 正则扩展 / Promise.finally / 异步迭代
- 03-28【Kotlin】扩展属性、扩展函数
- 03-28设计模式之建造者模式:灵活可扩展的对象创建过程
- 03-28elementPlus el-table动态列扩展及二维表格
- 03-28图像分割-RSPrompter-2. SAM的扩展