【ACM】poj_2210_Metric Time_201308011933

本文介绍了一种算法,用于将经典时间格式(如小时、分钟、秒、天、月、年)转换为公制时间格式。公制时间采用更简单的计数单位,如10小时每天、100分钟每小时等。文章提供了实现这一转换的C语言代码示例,并附带了样例输入输出。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Metric Time
Time Limit: 1000MS  Memory Limit: 65536K
Total Submissions: 2550  Accepted: 783

Description

The Metric Time is one of the most important points of PSOS Election Programme. The Time can be much easier calculated in operating systems. These systems are then more stable, which meets the main goal of the Party.

The length of one day is the same as with the "classic" time. The day is divided into 10 metric hours, each of them into 100 metric minutes, and each minute into 100 metric seconds. 10 metric days form one metric week, 10 metric weeks give one metric month, 10 metric months are called metric year. It is obvious this Metric Time is much better than the classic one.

Some opponent parties often complain that the Metric Time has also some drawbacks. First of all, it would be very difficult to change to the new time. PSOS Chairman decided to solve these problems all at once. He plans to publish a freeware utility which will be able to convert between the time formats. Your goal is to write one half of this utility, the program which converts classic time to Metric Time. Metric hours, metric minutes, and metric seconds are counted starting with zero, as usual. Metric days and metric months start with one. There exist metric year zero. The metric seconds should be rounded to the nearest smaller integer value. Assume that 0:0:0 1.1.2000 classic time is equal to 0:0:0 1.1.0 Metric Time.

Note that the classic year is leap, if it is an integer multiple of 4. The only exception are years divisible by 100 - they are leap only if they are an integer multiple of 400. For example, leap years are 1996, 2400, and 2000; leap years are not 1900, 2300, 2002.

Input

At the first line there is a positive integer N stating the number of assignments to follow. Each assignment consists of exactly one line in the form "hour:minute:second day.month.year" which is the date in the classic form (usual in most of European countries). The date is always valid, 2000 <= year <= 50000.
Output

The program must print exactly one line for each assignment. The line should have the form "mhour:mmin:msec mday.mmonth.myear" which is the Metric Time equal to the specified classic time.
Sample Input

7
0:0:0 1.1.2000
10:10:10 1.3.2001
0:12:13 1.3.2400
23:59:59 31.12.2001
0:0:1 20.7.7478
0:20:20 21.7.7478
15:54:44 2.10.20749

Sample Output

0:0:0 1.1.0
4:23:72 26.5.0
0:8:48 58.2.146
9:99:98 31.8.0
0:0:1 100.10.2000
0:14:12 1.1.2001
6:63:0 7.3.6848

 


#include <stdio.h>
#include <string.h>
int isRunNian(int n)
{
 if(n%400==0||(n%4==0&&n%100!=0))
 return 1;
 else
 return 0;
}//判断是否为闰年
int DiJiTian(int y,int m,int d)
{
 int i,total=0;
 for(i=1;i<m;i++)
 {
  if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
  total+=31;
  if(i==4||i==6||i==9||i==11)
  total+=30;
  if(i==2)
  {
   if(isRunNian(y))
   total+=29;
   else
   total+=28;
  }
 }
 for(i=2000;i<y;i++)
 {
  if(isRunNian(i))
  total+=366;
  else
  total+=365;
 }
 total+=d-1;
 return total;
}//判断该日期为这一年的第几天
int classictime(int n)
{
 //n=99999;
    int i,j,k,m;
 m=i=j=k=0;
 m=n/100000;
 n%=100000;
 i=n/10000;
 n%=10000;
 j=n/100;
 n%=100;
 k=n;
 printf("%d:%d:%d ",i,j,k);
 return m;
}
int classicdate(int n)
{
 //n=1000;
    int i,j,k,m;
 i=0;j=1;k=1;m=n;
 i=m/1000;
 m%=1000;
 j+=m/100;
 m%=100;
 k+=m;
 printf("%d.%d.%d\n",k,j,i);
 return 0;
}
int main()
{
 int N;
 scanf("%d",&N);
 getchar();
 while(N--){
 char s[22];
 int a[8]={0};
 int i,j,t,date,total,time;
 total=time=t=0;
 gets(s);
 //puts(s);
 for(j=0,i=0;i<strlen(s);i++)
 {
  if(s[i]!=':'&&s[i]!='.'&&s[i]!=' ')
  t=t*10+s[i]-'0';
  else
  {a[j++]=t;t=0;continue;}
  //printf("%d\n",t);
 }
 a[j]=t;
 date=DiJiTian(a[5],a[4],a[3]);
 //printf("%d\n",date);
 total=(int)(date*0.864);
 time=date*864-total*1000;
 time*=100;
 time+=a[0]*3600+a[1]*60+a[2];
 total+=(time/100000);
 time%=100000;
 total+=classictime(time);
 classicdate(total);
 //printf("%d\n",time);
 //for(i=0;i<6;i++)
 //printf("%d ",a[i]);
 }
 return 0;
}
//错误代码

 


#include <stdio.h>
#include <string.h>
int isRunNian(int n)
{
 if(n%400==0||(n%4==0&&n%100!=0))
 return 1;
 else
 return 0;
}//判断是否为闰年
int DiJiTian(int y,int m,int d)
{
 int i,total=0;
 for(i=1;i<m;i++)
 {
  if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
  total+=31;
  if(i==4||i==6||i==9||i==11)
  total+=30;
  if(i==2)
  {
   if(isRunNian(y))
   total+=29;
   else
   total+=28;
  }
 }
 for(i=2000;i<y;i++)
 {
  if(isRunNian(i))
  total+=366;
  else
  total+=365;
 }
 total+=d-1;
 return total;
}//判断该日期为这一年的第几天
int classictime(int n)
{
 //n=99999;
    int i,j,k;
 i=j=k=0;
 n%=100000;
 i=n/10000;
 n%=10000;
 j=n/100;
 n%=100;
 k=n;
 printf("%d:%d:%d ",i,j,k);
 return 0;
}
int classicdate(int n)
{
 //n=1000;
    int i,j,k,m;
 i=0;j=1;k=1;m=n;
 i=m/1000;
 m%=1000;
 j+=m/100;
 m%=100;
 k+=m;
 printf("%d.%d.%d\n",k,j,i);
 return 0;
}
int main()
{
 int N;
 scanf("%d",&N);
 getchar();
 while(N--){
 char s[22];
 int a[8]={0};
 int i,j,t,date,total,time;
 total=time=t=0;
 gets(s);
 //puts(s);
 for(j=0,i=0;i<strlen(s);i++)
 {
  if(s[i]!=':'&&s[i]!='.'&&s[i]!=' ')
  t=t*10+s[i]-'0';
  else
  {a[j++]=t;t=0;continue;}
  //printf("%d\n",t);
 }
 a[j]=t;
 date=DiJiTian(a[5],a[4],a[3]);
 //printf("%d\n",date); 
 time=(a[0]*3600+a[1]*60+a[2])/0.864;
 classictime(time); 
 classicdate(date);
 //printf("%d\n",time);
 //for(i=0;i<6;i++)
 //printf("%d ",a[i]);
 }
 return 0;
}
//AC

#include<stdio.h>
int main()
{  
     int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 
     int year,mon,day,hour,min,sec,myear,mmon,mday,mhour,mmin,msec;
     int i,n;
     scanf("%d",&n);
     while(n--)
     {
         scanf("%d%*c%d%*c%d%*c%d%*c%d%*c%d",&hour,&min,&sec,&day,&mon,&year);//这种输入比较好,值得学习
         for(i=1,m[0]=0;i<mon;i++)
             m[0]+=m[i];
         if(mon>2)
             if(year%4==0&&year%100!=0||year%400==0)
                 m[0]++;
         for(i=2000;i<year;i+=4)
             if(i%100!=0||i%400==0)
                 m[0]++;
         m[0]+=(year-2000)*365+day-1;
           myear=m[0]/1000;
         m[0]%=1000;
         mmon=m[0]/100;
         mday=m[0]%100;
         m[0]=(hour*3600+min*60+sec)/0.864;
         mhour=m[0]/10000;
         m[0]%=10000;
         mmin=m[0]/100;
         msec=m[0]%100;
         printf("%d:%d:%d %d.%d.%d\n",mhour,mmin,msec,mday+1,mmon+1,myear);
     }
     return 0;
}
//参考的别人的代码

转载于:https://www.cnblogs.com/xl1027515989/p/3231058.html

标题基于SpringBoot+Vue的社区便民服务平台研究AI更换标题第1章引言介绍社区便民服务平台的研究背景、意义,以及基于SpringBoot+Vue技术的研究现状和创新点。1.1研究背景与意义分析社区便民服务的重要性,以及SpringBoot+Vue技术在平台建设中的优势。1.2国内外研究现状概述国内外在社区便民服务平台方面的发展现状。1.3研究方法与创新点阐述本文采用的研究方法和在SpringBoot+Vue技术应用上的创新之处。第2章相关理论介绍SpringBoot和Vue的相关理论基础,以及它们在社区便民服务平台中的应用。2.1SpringBoot技术概述解释SpringBoot的基本概念、特点及其在便民服务平台中的应用价值。2.2Vue技术概述阐述Vue的核心思想、技术特性及其在前端界面开发中的优势。2.3SpringBoot与Vue的整合应用探讨SpringBoot与Vue如何有效整合,以提升社区便民服务平台的性能。第3章平台需求分析与设计分析社区便民服务平台的需求,并基于SpringBoot+Vue技术进行平台设计。3.1需求分析明确平台需满足的功能需求和性能需求。3.2架构设计设计平台的整体架构,包括前后端分离、模块化设计等思想。3.3数据库设计根据平台需求设计合理的数据库结构,包括数据表、字段等。第4章平台实现与关键技术详细阐述基于SpringBoot+Vue的社区便民服务平台的实现过程及关键技术。4.1后端服务实现使用SpringBoot实现后端服务,包括用户管理、服务管理等核心功能。4.2前端界面实现采用Vue技术实现前端界面,提供友好的用户交互体验。4.3前后端交互技术探讨前后端数据交互的方式,如RESTful API、WebSocket等。第5章平台测试与优化对实现的社区便民服务平台进行全面测试,并针对问题进行优化。5.1测试环境与工具介绍测试
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值