列表

详情


NC201606. Channels

描述

Nancy喜欢学习,也喜欢看电视。
为了想了解她能看多长时间的节目,不妨假设节目从时刻1开始,一直播放到时刻。每个节目持续50个时刻,节目与节目间会有10个时刻的广告时间。
然而,Nancy实在是太忙了,她从t_1时刻开始观看,观看至t_2时刻,请你帮忙计算她有多少个时刻能欣赏到电视节目。

输入描述

若干行:每行两个整数t_1t_2
数据满足:

输出描述

若干行:每行一个整数,表示能品味电视节目的时刻数。

示例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

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

pypy3(pypy3.6.1) 解法, 执行用时: 305ms, 内存消耗: 25936K, 提交时间: 2020-01-18 19:36:17

def calc(x):
    ans = x // 60 * 50
    return min(x % 60, 50) + ans

try:
    while True:
        t1, t2 = map(int, input().split())
        print(calc(t2) - calc(t1 - 1))
except EOFError:
    pass

C++14(g++5.4) 解法, 执行用时: 46ms, 内存消耗: 792K, 提交时间: 2020-01-20 10:48:35

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll a,b;
	while(cin>>a>>b){
		a-=1;	
	cout<<b/60*50+min(50*1LL,b%60)-a/60*50-min(50*1LL,a%60)<<endl;
	}
	return 0;
} 

C(clang11) 解法, 执行用时: 10ms, 内存消耗: 708K, 提交时间: 2020-12-31 12:48:51

#include<stdio.h>
#define min(a,b) (a<b ? a:b)
long long L,R;
int main() {
    while(~scanf("%lld%lld",&L,&R))
    printf("%lld\n",R/60*50+min(R%60,50)-((L-1)/60*50+min((L-1)%60,50)));
}

C++11(clang++ 3.9) 解法, 执行用时: 41ms, 内存消耗: 812K, 提交时间: 2020-01-24 00:20:34

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll a,b; while(cin>>a>>b) cout<<b/60*50+min(50ll,b%60)-(a-1)/60*50-min(50ll,(a-1)%60)<<'\n';
}

Python3(3.5.2) 解法, 执行用时: 184ms, 内存消耗: 4600K, 提交时间: 2020-02-01 20:58:49

while True:
	try:
		t1, t2 = map(int, input().split())
		b = (t1-1)//60*50+min((t1-1)%60,50)
		a = t2//60*50+min(t2%60,50)
		print(a-b)
	except Exception:
		break

上一题