Java-POJ1006-Biorhythms(中国剩余定理)
https://blog.csdn.net/shanshanpt/article/details/8724769
有中文题面,就不解释了。
妥妥的中国剩余定理没跑了。
Java跑得慢,一点办法也没有,必须写正解,暴力居然TLE
package poj.ProblemSet;
import java.util.Scanner;
public class poj1006 {
public static final int MOD = 23 * 28 * 33;
public static final int X1 = 28 * 33 * 6;
public static final int X2 = 23 * 33 * 19;
public static final int X3 = 23 * 28 * 2;
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
for (int p = cin.nextInt(), e = cin.nextInt(), i = cin.nextInt(), d = cin.nextInt(), n = 1; p != -1 && e != -1 && i != -1 && d != -1; p = cin.nextInt(), e = cin.nextInt(), i = cin.nextInt(), d = cin.nextInt()) {
int ans = (X1 * p + X2 * e + X3 * i - d + MOD) % MOD;
System.out.println("Case " + (n++) + ": the next triple peak occurs in " + (ans == 0 ? MOD : ans) + " days.");
}
}
}
poj1006
Java-POJ1006-Biorhythms(中国剩余定理)的更多相关文章
- POJ1006——Biorhythms(中国剩余定理)
Biorhythms Description人生来就有三个生理周期,分别为体力.感情和智力周期,它们的周期长度为23天.28天和33天.每一个周期中有一天是高峰.在高峰这天,人会在相应的方面表现出色. ...
- Biorhythms(中国剩余定理)
http://shuxueshi.jie.blog.163.com/blog/static/13611628820104179856631/ 这篇博客写的很棒! #include<stdio.h ...
- POJ 1006 - Biorhythms (中国剩余定理)
B - Biorhythms Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Subm ...
- POJ 1006 Biorhythms --中国剩余定理(互质的)
Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 103539 Accepted: 32012 Des ...
- POJ 1006 Biorhythms(中国剩余定理)
题目地址:POJ 1006 学习了下中国剩余定理.參考的该博客.博客戳这里. 中国剩余定理的求解方法: 假如说x%c1=m1,x%c2=m2,x%c3=m3.那么能够设三个数R1,R2,R3.R1为c ...
- PKU POJ 1006 Biorhythms (中国剩余定理)
中国剩余定理 x = ai (mod mi) ai和mi是一组数,mi两两互质,求x 令Mi = m1*m2*~mk 其中,mi不包含在内. 因为mi两两互质,所以存在x和y, st M ...
- poj1006 / hdu1370 Biorhythms (中国剩余定理)
Biorhythms 题意:读入p,e,i,d 4个整数,已知(n+d)%23=p; (n+d)%28=e; (n+d)%33=i ,求n . (题在文末) 知识点:中国剩余定理 ...
- poj1006 中国剩余定理&&中国剩余定理解析
poj 1006 题的思路不是很难的,可以转化数学式: 现设 num 是下一个相同日子距离开始的天数 p,e,i,d 如题中所设! 那么就可以得到三个式子:( num + d ) % 23 == p: ...
- 【中国剩余定理】 poj 1006
生理周期 简单模拟 对于超出23 * 28 * 33(21252)时进行求余运算即可. #include<stdio.h> int main() { //freopen("in ...
- Biorhythms(poj1006+中国剩余定理)
Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 117973 Accepted: 37026 Des ...
随机推荐
- 获取指定key对应的node节点信息
需求:之前写的脚本(https://www.cnblogs.com/imdba/p/10197192.html),每个node上都只有一个slot段范围的情况,本次通过测试,实现了,任意段范围的获取方 ...
- day5 dict嵌套
#!/usr/bin/env python # -*- coding:utf-8 -*- dic = { 'name': ['alex', 'wusir', 'taibai'], 'py9': { ' ...
- HTML+PHP+MySQL 制作最基础的登录页面及验证
第一步 进入mysql操作终端 新建一个数据库web1:create database web1; 然后在这个数据库里面新建一张表test:create table test(user varchar ...
- LeetCode 704. 二分查找
题目链接:https://leetcode-cn.com/problems/binary-search/ 给定一个 n 个元素有序的(升序)整型数组 nums 和一个目标值 target ,写一个函 ...
- AMCL论文及源码解析--参数(持续更新中)
整理内容来自:http://wiki.ros.org/amcl 1.AMCL订阅的节点: scan (sensor_msgs/LaserScan):激光数据 tf (tf/tfMessage):各种转 ...
- 问题 B: 基础排序III:归并排序
#include <cstdio> #include <vector> #include <algorithm> using namespace std; void ...
- Cloud保存时提示消息是否保存,点是保存,点否不保存。
业务场景:保存时,检查上游的销售出库单数量,和发货通知单数量是否一致,不一致时提示信息,点是则保存,点否不保存. using System;using System.Collections.Gener ...
- oracle Insert 一次插入多条记录
oracle Insert 一次插入多条记录有两种方法: 1)Insert All Into table_name values ... insert all into table_name valu ...
- jQuery---tab栏切换
tab栏切换 <!DOCTYPE html> <html> <head lang="en"> <meta charset="UT ...
- 2_abstractions
2. Up and down the level of abstraction In this chapter, we'll travel up and down the level of abstr ...