地址
https://codeforces.com/contest/1153/problem/A
原文地址
https://www.lucien.ink/archives/413
代码
#include <bits/stdc++.h>
int main() {
int n, m, min = 0x3f3f3f3f, ans, buf;
scanf("%d%d", &n, &m);
for (int i = 1, a, d; i <= n; i++) {
scanf("%d%d", &a, &d);
if (a >= m) buf = a - m;
else {
buf = d - (m - a) % d;
if (buf >= d) buf -= d;
}
if (buf < min) min = buf, ans = i;
}
printf("%d\n", ans);
return 0;
}