【POJ 1061】 青蛙的约会
【题目链接】
【算法】
列出同余方程,然后用exgcd求解
【代码】
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <stack>
#include <limits.h>
using namespace std; typedef long long LL; LL p,q,x,y,n,m,L,r; template <typename T> void read(T &x) {
LL f=; char c = getchar(); x=;
for (; !isdigit(c); c = getchar()) { if (c=='-') f=-; }
for (; isdigit(c); c = getchar()) x=x*+c-'';
x*=f;
} inline LL exgcd(LL a,LL b,LL &x,LL &y) {
LL r;
if (b == ) {
x = ;
y = ;
return a;
}else {
r = exgcd(b,a%b,y,x);
y -= a / b * x;
return r;
}
} int main() { read(x); read(y); read(m); read(n); read(L); r = exgcd(L,n-m,p,q); if ((x - y) % r) puts("Impossible");
else cout<< (((q * (x - y) / r) % L) + L) % L << endl; return ; }
【POJ 1061】 青蛙的约会的更多相关文章
- poj 1061 青蛙的约会 拓展欧几里得模板
		
// poj 1061 青蛙的约会 拓展欧几里得模板 // 注意进行exgcd时,保证a,b是正数,最后的答案如果是负数,要加上一个膜 #include <cstdio> #include ...
 - ACM:  POJ 1061 青蛙的约会 -数论专题-扩展欧几里德
		
POJ 1061 青蛙的约会 Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%lld & %llu Descr ...
 - POJ.1061 青蛙的约会 (拓展欧几里得)
		
POJ.1061 青蛙的约会 (拓展欧几里得) 题意分析 我们设两只小青蛙每只都跳了X次,由于他们相遇,可以得出他们同余,则有: 代码总览 #include <iostream> #inc ...
 - poj 1061 青蛙的约会 (扩展欧几里得模板)
		
青蛙的约会 Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Submit Status ...
 - POJ 1061青蛙的约会(拓展欧几里德算法)
		
题目链接: 传送门 青蛙的约会 Time Limit: 1000MS Memory Limit: 65536K Description 两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见 ...
 - POJ 1061 青蛙的约会
		
青蛙的约会 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 82859 A ...
 - poj 1061青蛙的约会
		
青蛙的约会 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 90083 Accepted: 16257 Descripti ...
 - POJ 1061 青蛙的约会 扩展欧几里德--解不定方程
		
青蛙的约会 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 81606 Accepted: 14116 Descripti ...
 - POJ 1061 青蛙的约会(拓展欧几里得求同余方程,解ax+by=c)
		
青蛙的约会 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 122871 Accepted: 26147 Descript ...
 - poj 1061 青蛙的约会 扩展欧几里德
		
青蛙的约会 Time Limit: 1000MS Memory Limit: 10000K Description 两 只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面.它们 ...
 
随机推荐
- c字符和字符数组/字符串
			
一维和二维的都可以:一维的情况如下:1,char string0[10];2,char string1[]="prison break";3,char string2[100]=& ...
 - ros使用罗技f710无线控制手柄
			
参考:blog.csdn.net/hcx25909/article/details/9042469 罗技F710无线控制手柄ROS下使用说明 安装手柄相关的包和驱动 sudo apt-get inst ...
 - DELPHI方法注释的标准写法
			
/// <summary> /// 查询数据 /// </summary> /// <param name="accountno">帐套号< ...
 - kafka-0.8.1.1总结
			
文件夹 一. 基础篇 1. 开篇说明 2. 概念说明 3. 配置说明 4. znode分类 5. kafka协议分类 6. Kafka线 ...
 - openURL
			
在iOS开发中,经常需要调用其它App,如拨打电话.发送邮件等.UIApplication:openURL:方法是实现这一目的的 在iOS开发中,经常需要调用其它App,如拨打电话.发送邮件等.UIA ...
 - 【Linux学习笔记】栈与函数调用惯例
			
栈与函数调用惯例(又称调用约定)— 基础篇 记得一年半前参加百度的校招面试时,被问到函数调用惯例的问题.当时只是懂个大概,比如常见函数调用约定类型及对应的参数入栈顺序等.最近看书过程中,重新回顾了这些 ...
 - OTT
			
http://baike.baidu.com/view/1315414.htm OTT 编辑 OTT 是“Over The Top”的缩写,是通信行业非常流行的一个词汇,这个词汇来源于篮球等体育运 ...
 - Android应用程序窗体View的创建过程
			
View类是android中非常重要的一个类.view是应用程序界面的直观体现,我们看到的应用程序界面就能够看作是View(视图)组成的. 那么我们应用程序的界面是怎么创建的呢,也就是应用程序的Vie ...
 - 李洪强iOS开发之 - 指定刷新tableview的某一组
			
李洪强iOS开发之 - 指定刷新tableview的某一组
 - error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
			
头文件函数声明少了“:(分号)”