Show More
Commit Description:
translates test_request input/output file paths for remote grading test_request
Commit Description:
translates test_request input/output file paths for remote grading test_request
References:
File last commit:
Show/Diff file:
Action:
test/data/test2_05sec.c
| 56 lines
| 974 B
| text/x-c
| CLexer
|
|
r51 | #include <stdio.h> | ||
#include <stdlib.h> | ||||
#include <unistd.h> | ||||
#include <time.h> | ||||
|
r114 | #include <windows.h> | ||
// run it for 0.5 s | ||||
|
r51 | |||
|
r114 | double get_running_time() | ||
{ | ||||
FILETIME creation_time; | ||||
FILETIME exit_time; | ||||
FILETIME kernel_time; | ||||
FILETIME user_time; | ||||
GetProcessTimes(GetCurrentProcess(), | ||||
&creation_time, | ||||
&exit_time, | ||||
&kernel_time, | ||||
&user_time); | ||||
SYSTEMTIME sys_kernel_time; | ||||
SYSTEMTIME sys_user_time; | ||||
FileTimeToSystemTime(&kernel_time, &sys_kernel_time); | ||||
FileTimeToSystemTime(&user_time, &sys_user_time); | ||||
double time_used = | ||||
((sys_kernel_time.wSecond + sys_kernel_time.wMilliseconds/1000.0) + | ||||
(sys_user_time.wSecond + sys_user_time.wMilliseconds/1000.0)); | ||||
return time_used; | ||||
} | ||||
|
r51 | |||
int main() | ||||
{ | ||||
int a,b; | ||||
int c=0; | ||||
|
r75 | int r; | ||
|
r51 | |||
|
r75 | r = scanf("%d %d",&a,&b); | ||
|
r51 | printf("%d\n",a+b); | ||
while(1) { | ||||
c++; | ||||
b+=c; | ||||
while(c<100000) { | ||||
c++; | ||||
b+=c; | ||||
} | ||||
|
r114 | if(get_running_time() > 0.5) | ||
|
r51 | break; | ||
} | ||||
printf("%d\n",b); | ||||
exit(0); | ||||
} | ||||