mioj + 1s

Copyright: spark https://blog.csdn.net/qq_35619728/article/details/89257583

Millet oj

Today wrote this question is relatively simple. . . . Two days before the psychological autistic gradually out. . . . Yesterday saw an article about fast sorting, speaking quite detailed attach a link to the toilet ... quick sort algorithm point of view it seems to me a bit like a dichotomy, indeed quite clever, and was the worst time complexity

+1s


description

In an ancient land of mystery, there is an elder, he has a special ability, that is able to continue their lives second, at the same time, the people around will be appropriate to -1s

Whenever the number of hours electronic table with the same number of minutes (24-hour, 00: 00: 00-23: 59: 59), that last one minute one second will disappear

That is to say, for example, 06: 06: 58 the next second will be 06:07:00

Now, after a period of coexistence with the elderly, for you, you spend time exactly how much


Entry

The elapsed time in the real world, the format is {D} days minutes {} {} {h} seconds, minutes and seconds complement 2


Export

For you, the time, the same input format


The general idea is to calculate the elderly will be more much longer than others, here in seconds to record. . . . Then use the second as a unit count how many young people can have more seconds, and back all day number, hours, minutes, seconds.

Oh yes I think of it. . The body also has a place. . . Must be obtained in accordance with the format of his direct when shaping encountered d jump out. . The problem there is a pit. . .

#include"stdio.h"

/*
输入样例
2d06 05 24
 复制样例
输出样例
2d06 04 30
*/
/*
一天会损失24*1    秒
完整的一小时损失一秒
*/ 
typedef struct
{
	int day;
	int hour;
	int min;
	int sec;
}time;

time young, old ;
int main(void)
{
	static int a, b[100];//数组用来获取元素
	static int num = 0;//用来算长者与我差的时间
	static int i, j, k;
	//time young,old=0;
	static char p = 0;

	while (~scanf_s("%d", &a))
	{

		  b[i++] = a;
		  p = getchar();
		  if (p == 'd')
			  break;
	}
	while (~scanf_s("%d", &a))
	{
		p = getchar();
		if (p == 'p')
			break;
		b[i++] = a;
	}
	old.day=b[0],old.hour = b[1], old.min = b[2],old.sec=b[3];//取出长者的时间
	num += old.day * 24;//加上天数
	for (j = 1; j <= 24; j++)
	{
		if (old.hour < j)
		{
			if (old.min > j)
				num += j ;
			else if(old.sec==59)
				num += j ;
		   else
				num += j-1;

			break;
		}
	}
	//old比长者多活num秒
	long long int sum_y = 0;
	sum_y = old.day * 24 * 3600 + old.hour * 3600 + old.min * 60 + old.sec - num;
	young.day = sum_y / (24 * 3600);
	young.hour = (sum_y- young.day*24*3600) / 3600;
	young.min = (sum_y-young.day*24*3600 - young.hour*3600)/60;
	young.sec = (sum_y- young.day * 24 * 3600 - young.hour * 3600 -young.min*60);

	printf("%d    %d   %d   %d \n",b[0],b[1],b[2],num);
	printf("%d  %d   %d   %d\n",young.day,young.hour,young.min,young.sec);

	printf("%dd", young.day);
	if (young.hour < 10)
		printf("0");
	    printf("%d", young.hour);
		printf(" ");
		if (young.min < 10)
	    printf("0");
		printf("%d", young.min);
		printf(" ");
		printf("%d", young.sec);


	scanf_s("%d",&a);

}

C language then barely operational efficiency

Here Insert Picture Description

Then a decisive skin. . C ++ does not modify the submitted directly
Here Insert Picture Description
hehe
! [Insert Picture description here] (https://img-blog.csdnimg.cn/2019041221003192.png

Btw, yesterday bought two books to today. . . . . . . Go back and look at night

Guess you like

Origin blog.csdn.net/qq_35619728/article/details/89257583