【洛谷OJ】P1424 小鱼的航程(改进版)

36 篇文章 0 订阅

import java.util.Scanner;

public class Main{
    private static Scanner cin;
    public static int DISTENCE = 250;
    public static int DAYS_A_WEEK = 5;
    
    public static void main(String args[])throws Exception {
        cin = new Scanner(System.in);
        int x = cin.nextInt();
        long n = cin.nextLong();
        long xn = 0;
        long ret = 0;
        long tmp = 0;
        if(x>=1 && x<=7 && n>0) {
            
            if(x>=1 && x<=5) {
                tmp = (x-1)*DISTENCE;
            }else if (x>5 && x<= 7) {
                tmp = DAYS_A_WEEK*DISTENCE;
            }
            
            xn = x + n - 1;
            
            long t1 = xn/7;
            long t2 = xn%7;
            if (t1 >0) {
                ret = t1*DAYS_A_WEEK*DISTENCE;
            }
            if(t2>=1 && t2<=5) {
                ret += t2*DISTENCE;
            }else if(t2>5 && t2<=7) {
                ret += DAYS_A_WEEK*DISTENCE;
            }
            
            ret = ret - tmp;
            
        }
        System.out.println(ret);
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值