hdu 1370 Biorhythms
中国剩余定理……、
链接http://acm.hdu.edu.cn/showproblem.php?pid=1370
/*************************************************************************
> File Name: xh.cpp
> Author: XINHUA
> Mail: 525799145@qq.com
> Created Time: 2013/7/11 星期四 17:46:00 新华
************************************************************************/ #include<iostream>
#include<stdio.h>
#include<algorithm>
#include<iomanip>
using namespace std;
int extend_gcd(int a,int b,int &x,int &y)
{
int m;
if(b==)
{
x=;y=;
return a;
}
else
{
m=extend_gcd(b,a%b,x,y);
int c=x;
x=y;
y=c-a/b*(y);
}
return m;
}
int mod(int a,int m)
{
int x,y,gcd;
gcd=extend_gcd(a,m,x,y);
if(gcd==)
{
if(x<)
x=(x%m+m)%m;
return x;
}
else return ;
}
int china(int m0[],int b[],int d)
{
int x,y,n,m=,a=-d;
int i;
for(i=;i<;i++) m*=m0[i];
for(i=;i<;i++)
{
n=m/m0[i];
extend_gcd(n,m0[i],x,y);
a=a+n*b[i]*x;
}
return a%m;
}
int main()
{
int p,e,i,d,k,sum,l=,m[]={
,,
},b[];
char c;
cin>>c;
while(cin>>p>>e>>i>>d)
{
if(p==-&&e==-&&i==-&&d==-)
break;
b[]=p;b[]=e;b[]=i;
sum=china(m,b,d);
if(sum<=) sum+=;
printf("Case %d: the next triple peak occurs in %d days.\n",++l,sum);
}
return ;
}
hdu 1370 Biorhythms的更多相关文章
- 【中国剩余定理】POJ 1006 & HDU 1370 Biorhythms
题目链接: http://poj.org/problem?id=1006 http://acm.hdu.edu.cn/showproblem.php?pid=1370 题目大意: (X+d)%23=a ...
- Biorhythms HDU - 1370 (中国剩余定理)
孙子定理: 当前存在三个式子,t%3=2,t%5=3,t%7=2.然后让你求出t的值的一个通解. 具体过程:选取3和5的一个公倍数t1能够使得这个公倍数t1%7==1,然后选取3和7的一个公倍数t2使 ...
- hdu 1370 Biorthythms 中国剩余定理
Biorhythms Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- hdu 1370 || poj 1006 简单的中国剩余定理或者暴力
Biorhythms Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Probl ...
- SQL递归方式实现省市区县级别查询
数据库脚本 CREATE TABLE [dbo].[Std_Area]( [Id] [int] NOT NULL, [Name] [nvarchar](50) NULL, [ParentId] [in ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- hdu 1573 X问题 (非互质的中国剩余定理)
X问题 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- [转] HDU 题目分类
转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...
- HDU ACM 题目分类
模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...
随机推荐
- SDRAM控制器
1 初始化以及load mode 寄存器1 初始化以及load mode 寄存器 2 时间表 这里会有几个重要的时间周期: 3 AUTO REFRESH (自动刷新) 4 CAS(CL delay) ...
- jquery 1.6发布后,增加prop()方法部分取代attr()方法
以前的jq中,全部使用attr来访问对象的属性,比如取一个图片的alt属性,就可以这样做$('#img').attr('alt'); 但是在某些时候,比如访问checkbox的disabled属性 ...
- centos中安装chromium和flash
安装环境:centos 6.5 64位 在centos中安装chromium 安装Google源 cd /etc/yum.repos.d/ sudo wget http://people.CentOS ...
- Mongodb Java Driver 参数配置解析
要正确使用Mongodb Java Driver,MongoClientOptions参数配置对数据库访问的并发性能影响极大. connectionsPerHost:与目标数据库能够建立的最大conn ...
- ckeditor增加上传图片的功能
1.配置config.js开启图片上传选项卡. CKEDITOR.editorConfig = function( config ) { config.filebrowserImageUploadUr ...
- PowerPoint Office Mix 插件
一个内嵌在PowerPoint里的一个教学工具,可以以PPT为核心录制视频. 点下面链接了解并安装 https://mix.office.com/ 首先这货是免费,当然是基于PowerPoint的基础 ...
- Visual Assist X破解方法
VC2008的破解方法:使用2008的朋友我就不多说了,直接拷贝到你选择的那个安装目录去,例如 C:\Program Files\Visual Assist\ ,直接运覆盖VA_X.dll 即可VC2 ...
- Redis 二:入门基本篇
.多数据库设置 - ,代表16个数据库 .glob风格通配符 keys * 返回所有 keys ba? 返回 bar keys b[a-z][a-z] 返回btt bar \x 匹配转义字符 .判断一 ...
- google calendar
1. user guide on google https://developers.google.com/google-apps/calendar/instantiate 2. google app ...
- 修改myeclipse的jsp模板
在myeclipse的安装目录下: C:\Users\Seeker\AppData\Local\MyEclipse Professional\plugins 找到com.genuitec.eclips ...