跳到正文

题解

题解:UVA1529 时钟

bsl_zcz约 1 分钟
原文

这是 2025年10月22日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2025年10月22日
收录
2025年12月12日
更新
2026年11月22日
篇幅
约 1 分钟
题目
UVA1529

版本

  1. v2当前
  2. v1

考点:前缀和。

C++
#include<bits/stdc++.h>
#define int long long
using namespace std;
double f[1000005];
int a,b,c,d;
signed main(){
	for(int i=1;i<=60;i++){
		f[i]=f[i-1]+720.0/11;
	}
	cout<<"Program 3 by team X \nInitial time Final time Passes \n";
	while(cin>>a>>b>>c>>d){
		int x=a*60+b,y=c*60+d,ans=0;
		if(x>y){
			y+=720;
		}
		for(int i=1;i<=60;i++){
			if(f[i]>=x&&f[i]<=y){
				ans+=1;
			}
		}
		printf("       %02d:%02d       %02d:%02d %7d\n",a,b,c,d,ans);
	}
	cout<<"End of program 3 by team X\n";
	return 0;
}