Created
May 29, 2012 15:08
-
-
Save Abreto/2828953 to your computer and use it in GitHub Desktop.
AStar2012-J
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void) | |
{ | |
int n = 0, m = 0; | |
int u = 0, d = 0, t = 0; | |
int l = 0, low = -1; | |
scanf("%d %d", &n, &m); | |
while(m--) | |
{ | |
scanf("%d %d", &u, &d); | |
t = (int)(( (n*d) / (u+d) ) + 1); | |
l = (u+d)*t-n*d; | |
if( ((l < low) && low >= 0) || (low < 0) ) | |
low = l; | |
} | |
printf("%d\n", low); | |
} |
t=((n_d)/(u d)) 1
->t=(n_d u d)/(u d)
l=(u d)t-n_d=n_d u d-n*d=u d.
当然,没考虑分数.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
t=((n_d)/(u d)) 1
->t=(n_d u d)/(u d)
l=(u d)t-n_d=n_d u d-n*d=u d.
当然,没考虑分数.