裸题,没什么好说的

第一个中国剩余定理

写暴力都过了。。可见这题有多水

代码:

#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
#define MAX 200000000
#define ull unsigned long long
const int MAXN = ;
int a[];
int m[]={,,};
int exgcd(int a,int b,int &x,int &y)
{
if(b==)
{
x=;y=;
return a;
}
int r=exgcd(b,a%b,x,y);
int t=x;
x=y;
y=(t-a/b*y);
return r;
}
int china(int n)
{
int M=;
int ans=;
int x,y,d;
for(int i=;i<n;i++)
{
M*=m[i];
}
for(int i=;i<n;i++)
{
int mi=M/m[i];
int x,y;
d=exgcd(mi,m[i],x,y);
ans=(ans+a[i]*mi*x)%M;
}
while(ans<)
ans+=M;
return ans;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
getchar();
int p,e,d,n,x,f;
int tt=;
int ans=;
while(scanf("%d%d%d%d",&a[],&a[],&a[],&d)&&(a[]!=-||a[]!=-||a[]!=-||d!=-))
{
tt++;
ans=china();
while(ans<=d)
ans+=;
printf("Case %d: the next triple peak occurs in %d days.\n",tt,ans-d);
}
while(t)
printf("\n");
}
return ;
}

poj1006 ( hdu1370 ):中国剩余定理裸题的更多相关文章

  1. POJ1006——Biorhythms(中国剩余定理)

    Biorhythms Description人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色. ...

  2. HDU 3579 Hello Kiki 中国剩余定理(合并方程

    题意: 给定方程 res % 14 = 5 res % 57 = 56 求res 中国剩余定理裸题 #include<stdio.h> #include<string.h> # ...

  3. poj1006 中国剩余定理&&中国剩余定理解析

    poj 1006 题的思路不是很难的,可以转化数学式: 现设 num 是下一个相同日子距离开始的天数 p,e,i,d 如题中所设! 那么就可以得到三个式子:( num + d ) % 23 == p: ...

  4. Biorhythms(中国剩余定理)

    http://shuxueshi.jie.blog.163.com/blog/static/13611628820104179856631/ 这篇博客写的很棒! #include<stdio.h ...

  5. 【题解】UVA756 Biorhythms (中国剩余定理)

    UVA756:https://www.luogu.org/problemnew/show/UVA756 思路 几乎是裸的中国剩余定理模板题 但是需要注意的是此题并不是求最小正整数解 而是求大于d的解 ...

  6. 51nod1079(中国剩余定理)

    题目链接: http://www.51nod.com/onlineJudge/user.html#!userId=21687 题意: 中文题诶~ 思路: 本题就是个中国剩余定理模板题,不过模拟也可以过 ...

  7. 【中国剩余定理】 poj 1006

    生理周期  简单模拟 对于超出23 * 28 * 33(21252)时进行求余运算即可. #include<stdio.h> int main() { //freopen("in ...

  8. 51nod1079 poj2891 中国剩余定理与其扩展

    题目链接:http://www.51nod.com/Challenge/Problem.html#!#problemId=1079 一个正整数K,给出K Mod 一些质数的结果,求符合条件的最小的K. ...

  9. [poj 2891] Strange Way to Express Integers 解题报告(excrt扩展中国剩余定理)

    题目链接:http://poj.org/problem?id=2891 题目大意: 求解同余方程组,不保证模数互质 题解: 扩展中国剩余定理板子题 #include<algorithm> ...

随机推荐

  1. FTP服务器上删除文件夹失败

    很多人都知道:要删除FTP服务器上的文件夹时,必须确保文件夹下面没有其他文件,否则会删除失败! 可是,有些服务器考虑到安全等因素,通常会隐藏以点开始的文件名,例如“.test.txt”.于是,有的坏人 ...

  2. Linux + Apache + MySql+ Php 配置虚拟主机

    win7:------------------------------------------------------------------------ NameVirtualHost *:80&l ...

  3. [React Testing] Intro to Shallow Rendering

    In this lesson, we walk through how to use one of React's Test Utilities (from thereact-addons-test- ...

  4. Yii PHP Framework有用新手教程

    说明:由于近期工作工作关系,须要开发一个在Linux下执行的Web Application,须要对如今比較流行的一些PHP框架做一个了解和评估,以下的这篇文章是笔者近期学习一个比較新的PHP Fram ...

  5. [小技巧][ASP.Net MVC Hack] 使用 HTTP 报文中的 Header 字段进行身份验证

    在一些 Web 系统中,身份验证是依靠硬件证书进行的:在电脑上插入 USB 证书,浏览器插件读取证书的相关信息,然后在发送 HTTP 登录请求时顺便在 Header 字段附加上身份信息.服务器端处理这 ...

  6. jQuery mouseover,mouseout事件多次执行的问题处理

    控制鼠标移上移下事件,在使用Jquery 的mouseover,mouseout事件时,元素内部含有其它元素,会造成该事件多次的触发的情况. 问题解析 在用到mouseover和mouseout事件来 ...

  7. LDAP-常用命令

    1.recreating default ads instance ./ [root@dhcppc2 ~]# dsadm delete /usr/local/dsee7/var/dcc/ads #de ...

  8. JQuery动态增加删除元素

    <form action="" method="post" enctype="multipart/form-data"> < ...

  9. Android推送等耗电原因剖析

    原文链接:http://www.jianshu.com/p/584707554ed7 Android手机有两个处理器,一个是Application Processor(AP)基于ARM处理器,主要运行 ...

  10. BubbleSort - 实用委托

    概述: 排序类,可以对任意类型的对象进行排序,包括基本数据类型; 对象类,不仅定义本身数据,同时包含了排序的细节. 排序类(BubbleSorter): using System; using Sys ...