UVA - 10683
题目介绍:
In the first years following the French Revolution, intellectuals were set to outroot the society from
the traditions and superstitions the dark ages of the royalty. Some of these contributions have had a
worldwide success, such as the metric system. Others have falled into (almost) complete oblivion, such
as the decimal clock system, invented by the mathematician Gilbert Romme. The decimal clock system
divides the day in 10 decimal hours, themselves divided in 100 decimal minutes, themselves divided
into 100 decimal seconds.
You are commissioned by the international watch maker “Splatch” to include yet another useless
feature in their next line of product: decimal time display. Your first task will be to implement a
program that converts a traditional time into a decimal time at the precision of one-hundredth of
second.
大意:
时间变换,按比例变就行了,不需要四舍五入。
AC代码:
#include<iostream>
#include<cstring>
using namespace std;
const int mul[]={0,60,60,100};
int main(){
string que;
while(cin>>que){
double now=0;
int h_m_s[4];
for(int i=0;i<4;i++)
h_m_s[i]=10*(que[2*i]-'0')+que[2*i+1]-'0';
for(int i=0;i<4;i++)
now=now*mul[i]+h_m_s[i];
now=125*now/108;
int ans=now;
printf("%07d\n",ans);
}
return 0;
}