UVA - 10683

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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值