PAT (Basic Level) Practise (中文) 1026. 程序运行时间(15)
来源:互联网 发布:linux 复制目录及文件 编辑:程序博客网 时间:2024/05/16 16:07
- 程序运行时间(15)
时间限制
200 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue
要获得一个C语言程序的运行时间,常用的方法是调用头文件time.h,其中提供了clock()函数,可以捕捉从程序开始运行到clock()被调用时所耗费的时间。这个时间单位是clock tick,即“时钟打点”。同时还有一个常数CLK_TCK,给出了机器时钟每秒所走的时钟打点数。于是为了获得一个函数f的运行时间,我们只要在调用f之前先调用clock(),获得一个时钟打点数C1;在f执行完成后再调用clock(),获得另一个时钟打点数C2;两次获得的时钟打点数之差(C2-C1)就是f运行所消耗的时钟打点数,再除以常数CLK_TCK,就得到了以秒为单位的运行时间。
这里不妨简单假设常数CLK_TCK为100。现给定被测函数前后两次获得的时钟打点数,请你给出被测函数运行的时间。
输入格式:
输入在一行中顺序给出2个整数C1和C1。注意两次获得的时钟打点数肯定不相同,即C1 < C2,并且取值在[0, 107]。
输出格式:
在一行中输出被测函数运行的时间。运行时间必须按照“hh:mm:ss”(即2位的“时:分:秒”)格式输出;不足1秒的时间四舍五入到秒。
输入样例:
123 4577973
输出样例:
12:42:59
#include<iostream>using namespace std;int main(){ freopen("in.txt","r",stdin); int beginTime,endTime; while(cin>>beginTime>>endTime){ int duaTime=(endTime-beginTime+50)/100; int tt=(duaTime/60)/60; int mm=(duaTime/60)%60; int ss=duaTime%60%60; if(tt<10){ cout<<"0"<<tt<<":"; }else{ cout<<tt<<":"; } if(mm<10){ cout<<"0"<<mm<<":"; }else{ cout<<mm<<":"; } if(ss<10){ cout<<"0"<<ss; }else{ cout<<ss; } } return 0;}
0 0
- PAT (Basic Level) Practise (中文)1026. 程序运行时间
- PAT (Basic Level) Practise (中文)1026. 程序运行时间(15)
- PAT (Basic Level) Practise (中文) 1026. 程序运行时间(15)
- PAT (Basic Level) Practise (中文)1026. 程序运行时间(15) C语言
- PAT (Basic Level) Practise (中文)1026. 程序运行时间(15)
- PAT (Basic Level) Practise (中文) 1026. 程序运行时间(15)
- PAT (Basic Level)1026. 程序运行时间
- PAT (Basic Level) Practise (中文)
- PAT (Basic Level) Practise (中文)
- PAT (Basic Level) Practise (中文)--1001
- PAT (Basic Level) Practise (中文)
- PAT (Basic Level) Practise (中文)1001
- PAT (Basic Level) Practise (中文)1002
- PAT (Basic Level) Practise (中文) 1007
- PAT BASIC LEVEL 1026. 程序运行时间(15)
- PAT (Basic Level) Practise (中文)1021. 个位数统计 (15)
- PAT (Basic Level) Practise (中文)-1021. 个位数统计 (15)
- PAT (Basic Level) Practise (中文)1021. 个位数统计 (15)
- Project Management Life Cycle-Predictive & Iterative & Adaptive
- HDU 3584 Cube
- Single Number II
- HDU 2519 组合数基础
- PAT 1080 Graduate Admission
- PAT (Basic Level) Practise (中文) 1026. 程序运行时间(15)
- codeforces 107C Arrangement (状压dp)
- 【Uva 232】 Crossword Answers
- POJ 3169 Layout(差分约束基础)
- HDU 5176 The Experience of Love(带权并查集)
- 第三方应用分享到微信朋友圈功能
- LPC2138编程时出现错误“Timer.sct(7): error: L6236E: No section matches selector - no section to be FIRST/LAS
- java软件复杂运算,同时显示进度条的一种方法
- 一款桌面英语翻译软件介绍