poj2673

简单题

View Code
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using namespace std;

int t, x, m;
int n;

void input()
{
scanf("%d%d%d", &t, &x, &m);
n = 0x3f3f3f3f;
for (int i = 0; i < m; i++)
{
int a, b;
scanf("%d%d", &a, &b);
n = min(n, (a - 1) / b + 1);
}
}

void work()
{
int ans = 0;
if (n - 1 >= t)
{
printf("%d\n", t * x);
return;
}
if (n - 1 == 0)
{
printf("0\n");
return;
}
ans += n - 1;
t -= n - 1;
ans += t / 2;
printf("%d\n", ans * x);
}

int main()
{
//freopen("t.txt", "r", stdin);
input();
work();
return 0;
}

你可能感兴趣的:(poj)