百炼OJ1006
来源:互联网 发布:java文件乱码 编辑:程序博客网 时间:2024/04/30 05:46
Since the three cycles have different periods, the peaks of the three cycles generally occur at different times. We would like to determine when a triple peak occurs (the peaks of all three cycles occur in the same day) for any person. For each cycle, you will be given the number of days from the beginning of the current year at which one of its peaks (not necessarily the first) occurs. You will also be given a date expressed as the number of days from the beginning of the current year. You task is to determine the number of days from the given date to the next triple peak. The given date is not counted. For example, if the given date is 10 and the next triple peak occurs on day 12, the answer is 2, not 3. If a triple peak occurs on the given date, you should give the number of days to the next occurrence of a triple peak.
Case 1: the next triple peak occurs in 1234 days.
Use the plural form ``days'' even if the answer is 1.
0 0 0 00 0 0 1005 20 34 3254 5 6 7283 102 23 320203 301 203 40-1 -1 -1 -1
Case 1: the next triple peak occurs in 21252 days.Case 2: the next triple peak occurs in 21152 days.Case 3: the next triple peak occurs in 19575 days.Case 4: the next triple peak occurs in 16994 days.Case 5: the next triple peak occurs in 8910 days.Case 6: the next triple peak occurs in 10789 days.这个题涉及数论中的剩余定理,先跳过去,过几天去图书馆找本数论看看。
import java.util.Scanner;public class Main {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stubScanner sc = new Scanner(System.in);int n = 0;while (sc.hasNext()) {int p = sc.nextInt();int e = sc.nextInt();int i = sc.nextInt();int d = sc.nextInt();if (p == -1 && e == -1 && i == -1 && d == -1) {break;}n++;int days = (5544 * p + 14421 * e + 1288 * i - d) % (21252);if (days <= 0) {days = 23 * 28 * 33 + days;}System.out.println("Case " + n+ ": the next triple peak occurs in " + days + " days.");}}}
0 0
- 百炼OJ1006
- 北大OJ1006
- 南师oj1006
- 百炼
- [JAVA]杭电OJ1006
- 百炼采药问题....
- 百炼 1833:排列
- 百炼-2726:采药
- poj百炼 2788
- 【LIS】百炼-2757
- 百炼OJ1001
- 百炼OJ1002
- 百炼OJ1003
- 百炼OJ1004
- 百炼OJ1005
- 百炼OJ1007
- 百炼OJ1009
- 百炼 Zipper 剪枝
- AFNetWorking 检测网络状态
- Android Fragment详解(五):Fragment与Activity通讯
- go基本语法学习笔记之面向对象
- Autodesk 3ds Max 2013 官方中文版+英文版下载
- js播放wav格式的录音文件
- 百炼OJ1006
- PHP调试环境搭建:wampserver2.4+zend studio12.0.1+Xdebug
- 基于CoreAudio获取声卡输出电平
- gRPC异步处理应答
- 【bcb 6.0】http相关的控件
- ssh-keygen和ssh-copy-id实现SSH无密码登录
- 如何变得有思想
- Unity3d OnApplicationPause与OnApplicationFocus
- Android短信验证码的自动填写