Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

贴一下AC代码

Posted by cavatina2016 at 2019-03-10 21:30:40 on Problem 2854
#include <stdio.h>
#include <cmath>
#include <cstring>


int T[5];


int calc()
{
	double a = (double)(T[4] - T[1]) / (T[2] - T[1]);
	double b = (double)(T[2] - T[0]) / (T[3] - T[0]);
	double res = (a - 1) / (a * b - 1) * (T[1] - T[0]);
	return (int)floor(res + T[0] + 0.5);
}


int main()
{
	while (true) {
		for (int i = 0; i < 5; ++i) {
			int h, m, s;
			if (scanf_s("%d:%d:%d", &h, &m, &s) < 3) {
				return 0;
			}
			T[i] = h * 3600 + m * 60 + s;
		}

		int res = calc();
		printf("%02d:%02d:%02d\n", res / 3600, res % 3600 / 60, res % 60);
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator