Skip to content

Instantly share code, notes, and snippets.

@zxytim
Created November 22, 2012 14:47
Show Gist options
  • Save zxytim/4131526 to your computer and use it in GitHub Desktop.
Save zxytim/4131526 to your computer and use it in GitHub Desktop.
#include <sys/time.h>
#include <cmath>
#include <cstdio>
typedef unsigned long long time_ms_t;
time_ms_t get_time()
{
static timeval tv;
gettimeofday(&tv, 0);
return tv.tv_sec * 1000 + tv.tv_usec * 0.001;
}
time_ms_t start_time;
bool time_up(time_ms_t time_limit)
{
return get_time() - start_time > time_limit;
}
int main()
{
int n, m;
scanf("%d%d", &n, &m);
time_ms_t start_time = get_time(),
time_limit = pow(n * m, 1/ 6.0) * 1000 * 0.9;
while (get_time() - start_time < time_limit);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment