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

附上效率优化过的, 应该没有比这效率高的了吧

Posted by wm3418925 at 2016-09-07 22:05:47 on Problem 3751
#include <stdio.h>
int main() {
	int t;
	unsigned int s[6], r[6];
	short h;
	char ch;
	
	((char *)r)[2] = '/';
	((char *)r)[5] = '/';
	((char *)r)[10] = '-';
	((char *)r)[13] = ':';
	((char *)r)[20] = 'm';
	((char *)r)[21] = '\0';//其实20和21可以合并为一个short, 减少一次赋值
	
	scanf("%d",&t);
	for (--t; t>=0; --t) {
		scanf("%s", ((char *)s));
		
		h = (((char *)s)[11] - '0')*10 + (((char *)s)[12] - '0');
		
		if (h >= 12) {ch = 'p';h-=12;}
		else ch = 'a';
		
		if (h == 0) h = 12;
		
		
		((char *)r)[0] = ((char *)s)[5];
		((char *)r)[1] = ((char *)s)[6];
		
		((char *)r)[3] = ((char *)s)[8];
		((char *)r)[4] = ((char *)s)[9];
		
		((unsigned short *)r)[3] = *((unsigned short *)s);
		((unsigned short *)r)[4] = ((unsigned short *)s)[1];
		
		((char *)r)[11] = (h/10)+'0';
		((char *)r)[12] = (h%10)+'0';
		
		((unsigned short *)r)[7] = ((unsigned short *)s)[7];
		((unsigned short *)r)[8] = ((unsigned short *)s)[8];
		((char *)r)[18] = ((char *)s)[18];
		((char *)r)[19] = ch;
		
		
		puts((char *)r);
	}
	
	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