看大佬的代码都好复杂(不愧是大佬\(orz\)

蒟蒻提供一种思路

因为求的是最近的车对吧\(qwq\)

所以我们可以用一个\(while\)循环所以没必要去用什么 \(for...\)

至于这是\(div2\)的第一题还是比较水的

#include <bits/stdc++.h>
#define rep(i,j,n) for(register int i=j;i<=n;i++)
#define Rep(i,j,n) for(register int i=j;i>=n;i--)
#define low(x) x&(-x)
using namespace std ;
typedef long long LL ;
const int inf = INT_MAX >> 1 ;
inline LL In() { LL res(0) , f(1) ; register char c ;
#define gc c = getchar()
while(isspace(gc)) ; c == '-' ? f = - 1 , gc : 0 ;
while(res = (res << 1) + (res << 3) + (c & 15) , isdigit(gc)) ;
return res * f ;
#undef gc
} int n , t ;
const int N = 100 + 5 ;
struct node {
int s , d ;
}a[N] ;
inline void Ot() {
n = In() , t = In() ;
rep(i,1,n) a[i].s = In() , a[i].d = In() ;
int tmp = inf ;
int ans = 0 ;
rep(i,1,n) {
int s = a[i].s ;
while(s < t) s += a[i].d ;
if(tmp > (s-t)) tmp = (s-t) , ans = i ;
}
cout << ans << endl ;
}
signed main() {
// freopen("test.in","r",stdin) ;
return Ot() , 0 ;
}

随机推荐

  1. Linux清除arp缓存

    arp缓存就是IP地址和MAC地址关系缓存列表.在Windows下 arp -d [$ip] 不指定IP地址时清除所有arp缓存.在Linux下 arp -d $ip 必须指定IP地址才能执行这条命令 ...

  2. hdu 5029树链剖分

    /* 解:标记区间端点,按深度标记上+下-. 然后用线段树维护求出最小的,再将它映射回来 */ #pragma comment(linker, "/STACK:102400000,10240 ...

  3. MVC Ajax.BeginForm重复提交解决方法

    mvc使用MVC Ajax.BeginForm提交的时候有重复提交结果的时候检查相关js文件引用情况, 其中mvc4注意 1 2 3 4 @Scripts.Render("~/bundles ...

  4. baidu 和 es 使用

    http://www.cnblogs.com/kangoroo/p/8047586.html

  5. Codeforces 628D Magic Numbers

    题意: 求在[a,b](a,b不含前导0)中的d−magic数中有多少个是m的倍数. 分析: 计数dp Let's call a number d-magic if digit d appears i ...

  6. JSON与对象之间的转换

    import com.alibaba.fastjson.JSON;import com.fasterxml.jackson.databind.ObjectMapper;import com.faste ...

  7. Ubuntu 16.04使用百度云的方案

    Ubuntu没有很好的解决方案,都是一些投机取巧的方案: 1.不建议安装百度云客户端,尤其对于免费用户来说,会限制速度. 2.可以使用网页版进行文件上传. 3.下载可以通过Chrome点击下载后,复制 ...

  8. [React] Preview and edit a component live with React Live

    In this lesson we'll use React Live to preview and edit a component directly in the browser. React L ...

  9. Scala界面事件处理

    演示样例代码: import scala.swing.SimpleSwingApplication import scala.swing.MainFrame import scala.swing.Bu ...

  10. JavaScript基础 -- DOM

    一.DOM全称 文档对象模型(Document Object Model) 二.DOM是什么 DOM可以说是制作动态页面的强有力工具.DOM不是JavaScript语言的一部分,而是内置在浏览器中的一 ...