http://poj.org/problem?id=1006

#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#define inf 2147483647
#define N 1000010
#define p(a) putchar(a)
#define For(i,a,b) for(long long i=a;i<=b;++i)
//by war
//2019.8.8
using namespace std;
long long p,e,i,d,ans,m,x,y,cnt;
long long a[],b[];
void in(long long &x){
long long y=;char c=getchar();x=;
while(c<''||c>''){if(c=='-')y=-;c=getchar();}
while(c<=''&&c>=''){ x=(x<<)+(x<<)+c-'';c=getchar();}
x*=y;
}
void o(long long x){
if(x<){p('-');x=-x;}
if(x>)o(x/);
p(x%+'');
} void exgcd(long long a,long long b,long long &x,long long &y){
if(!b){
x=;y=;
return ;
}
exgcd(b,a%b,y,x);
y-=a/b*x;
} signed main(){
a[]=;a[]=;a[]=;
a[]=a[]*a[]*a[];
while(cin>>b[]>>b[]>>b[]>>d&&(b[]!=-)){
ans=;
For(i,,){
m=a[]/a[i];
exgcd(m,a[i],x,y);
x=(x%a[i]+a[i])%a[i];
ans=(ans+b[i]*m*x)%a[];
}
ans=((ans-d)%a[]+a[])%a[];
if(ans==)
ans=a[];
cout<<"Case "<<++cnt<<": the next triple peak occurs in "<<ans<<" days."<<endl;
}
return ;
}

中国剩余定理模数互质的情况模板(poj1006的更多相关文章

  1. Hello Kiki(中国剩余定理——不互质的情况)

    Hello Kiki Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  2. POJ 1006 Biorhythms --中国剩余定理(互质的)

    Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 103539   Accepted: 32012 Des ...

  3. poj 2981 Strange Way to Express Integers (中国剩余定理不互质)

    http://poj.org/problem?id=2891 Strange Way to Express Integers Time Limit: 1000MS   Memory Limit: 13 ...

  4. hdu X问题 (中国剩余定理不互质)

    http://acm.hdu.edu.cn/showproblem.php?pid=1573 X问题 Time Limit: 1000/1000 MS (Java/Others)    Memory ...

  5. HDU 5768 Lucky7 容斥原理+中国剩余定理(互质)

    分析: 因为满足任意一组pi和ai,即可使一个“幸运数”被“污染”,我们可以想到通过容斥来处理这个问题.当我们选定了一系列pi和ai后,题意转化为求[x,y]中被7整除余0,且被这一系列pi除余ai的 ...

  6. X问题(中国剩余定理+不互质版应用)hdu1573

    X问题 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  7. Strange Way to Express Integers(中国剩余定理+不互质)

    Strange Way to Express Integers Time Limit:1000MS Memory Limit:131072KB 64bit IO Format:%I64d & ...

  8. 中国剩余定理模数不互质的情况(poj 2891

    中国剩余定理模数不互质的情况主要有一个ax+by==k*gcd(a,b),注意一下倍数情况和最小 https://vjudge.net/problem/POJ-2891 #include <io ...

  9. HDU3579Hello Kiki(中国剩余定理)(不互质的情况)

    One day I was shopping in the supermarket. There was a cashier counting coins seriously when a littl ...

随机推荐

  1. python爬虫教程之美丽汤(一)

    python 爬虫之美丽汤 BeautifulSoup 作者: jwang106 1. 使用requests获取网页的html源码 import requests from bs4 import Be ...

  2. ionic-CSS:ionic 列表

    ylbtech-ionic-CSS:ionic 列表 1.返回顶部 1. ionic 列表 列表是一个应用广泛的界面元素,在所有移动app中几乎都会使用到. 列表可以是基本文字.按钮,开关,图标和缩略 ...

  3. 20140502 static_cast和dynamic_cast的类型检查 双链表建立,删除,打印

    1.static_cast和dynamic_cast的类型检查 static_cast的类型检查:只检查无关类之间的转换 CBaseY* pY1 = static_cast<CBaseY*> ...

  4. selenium基础-跳过验证码

    selenium基础-跳过验证码 一.方法 设置万能验证码或者屏蔽验证码(最常用的方法) 使用验证码识别工具识别验证码 通过selenium操作cookies 直接使用配置文件的webdriver 二 ...

  5. FlyMcu下载时的问题

    引用:http://www.openedv.com/forum.php?mod=viewthread&tid=69398&page=1#pid396135 和楼下李智鹏用普中科技的ST ...

  6. AndroidStudio 搜索导入自己需要的库

    前言 在Androidx的库应用后,导致有需多系统组件库需要重新 implementation 升级为Androidx, 但是你可能会发现不知道怎么导入他们.  当然除了导入Android的组件库,还 ...

  7. String = ""和String = null的区别

    在这要先说明下 String str;和String str=null;的关系,代码上来说两者几乎不差什么,但是这里String str=null;多了个指向空的引用 而String str ;却只是 ...

  8. Gamma(1)

    目前为止看到的解释Gamma来由说得最清楚的一篇文章:https://www.cambridgeincolour.com/tutorials/gamma-correction.htm 几点总结. 1, ...

  9. Flask框架图

  10. 校园商铺-4店铺注册功能模块-3thumbnailator图片处理和封装Util

    1. 初步使用thumbnailator 1.1 下载依赖 <!-- https://mvnrepository.com/artifact/net.coobird/thumbnailator - ...