题目背景
原来的题目太简单,现改进让小鱼周末也休息,请已经做过重做该题。
题目描述
有一只小鱼,它平日每天游泳 250 公里,周末休息(实行双休日),假设从周 x(1\le x \le 7)x(1≤x≤7) 开始算起,过了 n(n\le 10^6)n(n≤106) 天以后,小鱼一共累计游泳了多少公里呢?
输入格式
输入两个整数x,n(表示从周x算起,经过n天)。
输出格式
输出一个整数,表示小鱼累计游泳了多少公里。
代码
/*
* @Author: Gehrychiang
* @Date: 2019-08-21 20:07:56
* @Last Modified by: Gehrychiang
* @Last Modified time: 2019-08-21 20:11:59
* @Email:gehrychiang@ailiyun.com
* @Website:www.yilantingfeng.site
*/
#include <iostream>
using namespace std;
int main()
{
int weekday;
int totaldays;
cin>>weekday;
cin>>totaldays;
int totaljourney;
int table[7]={250,250,250,250,250,0,0};
int i;
int tmp=weekday-1;
for (i = weekday-1; i < totaldays+weekday-1; ++i)
{
totaljourney=totaljourney+table[tmp];
if (tmp==6)
{
tmp=-1;
}
++tmp;
}
cout<<totaljourney<<endl;
return 0;
}