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 ...
随机推荐
- 游戏对象的变换-Transform
问题: 在给GameObject设置位置的时候,怎么保证设置的位置在摄像机的范围内? 主要看摄像机的深度轴和你的GameObject的深度轴,比如如果现在的平面是: Z–> Y, ...
- 【风马一族_Java】java的一种IDE
IntelliJ IDEA 14 下载地址: IntelliJ IDEA 14 下载 分享几个license: (1) key:IDEA value:61156-YRN2M-5MNCN-NZ8D2-7 ...
- 【风马一族_Android】第4章Android常用基本控件
第4章Android常用基本控件 控件是Android用户界面中的一个个组成元素,在介绍它们之前,读者必须了解所有控件的父类View(视图),它好比一个盛放控件的容器. 4.1View类概述 对于一个 ...
- 《iptables详解 》RHEL6
iptables详解 Iptables原理 现在防火墙主要分以下三种类型:包过滤.应用代理.状态检测 包过滤防火墙:现在静态包过滤防火墙市面上已经看不到了,取而代之的是动态包过滤技术 ...
- Java IO流详尽解析
流的概念和作用 学习Java IO,不得不提到的就是JavaIO流. 流是一组有顺序的,有起点和终点的字节集合,是对数据传输的总称或抽象.即数据在两设备间的传输称为流,流的本质是数据传输,根据数据传输 ...
- iOS实现图片的缩放和居中显示
直接上代码 // // MoveScaleImageController.h // MoveScaleImage // // Created by on 12-4-24. // Copyright ( ...
- 11g RAC R2 体系结构---进程,日志
进程结构:Overview of Oracle Clusterware Platform-Specific Software Components When Oracle Clusterware is ...
- 笨办法学 Python (第三版)(转载)
笨办法学 Python (第三版) 原文地址:http://blog.sina.com.cn/s/blog_72b8298001019xg8.html 摘自https://learn-python ...
- [Environment Build] 如何实现Visual Studio中的区域语言环境切换
最开始学习C#这门语言的时候,英文能力不够好,安装的中文版本的Visual Studio,现在工作有段时间了,公司又是个外企,慢慢不习惯中文版本的了,于是产生了想切换语言的想法,网上搜索了下,下载了个 ...
- mysql 查询
查询数据:select s_name from student limit 1;//限制数量 select * from student where s_id in (select s_id from ...