Channels

链接:https://ac.nowcoder.com/acm/contest/11424/C
来源:牛客网

题目描述
Nancy喜欢学习,也喜欢看电视。
为了想了解她能看多长时间的节目,不妨假设节目从时刻1开始,一直播放到时刻6 \times 10^{100}6×10
100
。每个节目持续50个时刻,节目与节目间会有10个时刻的广告时间。
然而,Nancy实在是太忙了,她从t_1t
1

时刻开始观看,观看至t_2t
2

时刻,请你帮忙计算她有多少个时刻能欣赏到电视节目。
输入描述:
若干行:每行两个整数t_1t
1

与t_2t
2


数据满足:1 \leq t_1 \leq t_2 \leq 10^{18}1≤t
1

≤t
2

≤10
18

输出描述:
若干行:每行一个整数,表示能品味电视节目的时刻数。
示例1
输入
复制
1 61
输出
复制
51
示例2
输入
复制
116969978 507978500
180480072 791550396
139567120 655243745
1470545 167613747
57644034 176077476
44676 56984808
215706822 369042088
108368065 320914746
输出
复制
325840433
509225275
429730516
138452673
98694536
47450113
127779387
177122232

因为题目说是按照1开始算的,但是这样有很多边界问题,我们所以先都减1,这样就离散成从0开始算的,然后1----59是一组,以此类推

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <ext/rope>
#include <bits/stdc++.h> 

using namespace std;

#define gt(x) x = read()
#define int long long
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

const int mod = 1e9 + 7;
const int PP = 131;

inline int read(int out = 0)
{
    
    
    char c;
    while((c=getchar()) < 48 || c > 57);
    while(c >= 48 && c <= 57) out=out*10+c-48,c=getchar();
    return out; 
}

const int N = 1e5 + 10;
const int M = 1e6 + 10;

signed main(){
    
    
	int t1, t2;
	while(~scanf("%lld%lld", &t1, &t2)){
    
    
        t1 --;
        t2 --;
			int ans = 0;
	int temp = t1 % 60;
//	cout << temp << endl;
	temp = (60 - temp);
//	cout << temp << endl;
	if (temp >= 10){
    
    
		ans += (temp - 10);
	}
//	cout << ans << endl;
	t1 += temp;
	//cout << t1 << endl;
	temp = (t2 % 60);
	//cout << temp << endl;
	if (temp >= 49)  ans += 50;
	else    ans += temp + 1;
	//cout << ans << endl;
	t2 -= temp;
//	cout << t2 << endl;
	temp = (t2 - t1) / 60;
	//cout << temp << endl;
	ans += (temp * 50);
//	cout << ans << endl;
	
	cout << ans  << endl;	
	}
	
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_45772483/article/details/112718957