$CF1153A\ Serval\ and\ Bus$
看大佬的代码都好复杂(不愧是大佬\(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 ;
}
随机推荐
- 在ubuntu 18.04下装有线守护wg
wg你懂的是什么,下面讲讲我这段时间安装过程,发觉这个软件和CENTOS 7下面不是很合拍,它更适合ubuntu,因为ubuntu仍然用iptables,而CENTOS 早就用了firewalld了, ...
- [luoguP1019] 单词接龙(DFS)
传送门 不知为什么,判断全部包含反而A不了,不判断反而A了,╮(╯▽╰)╭ 代码 #include <cstdio> #include <iostream> #define m ...
- Codeforces Round #264 (Div. 2) D
题意: 给出最多5个序列,问这几个序列的最长公共子序列的长度是多少. solution : 脑抽级别我是,第一个序列每个数字位置固定,这样只要维护一个k-1维的偏序集就好了.然后在保证每个位置合法的情 ...
- bzoj3545 Peaks 线段树合并
离线乱搞... 也就是一个线段树合并没什么 #include<algorithm> #include<iostream> #include<cstring> #in ...
- codevs3285 转圈游戏
题目描述 Description n 个小伙伴(编号从 0 到 n-1)围坐一圈玩游戏.按照顺时针方向给 n 个位置编号,从0 到 n-1.最初,第 0 号小伙伴在第 0 号位置,第 1 号小伙伴在第 ...
- Java日期LocalDate使用
在做报表统计时,需要对指定时间内的数据做统计,则需要使用到时间日期API 在此使用的是java.util.Date的完美私生子LocalDate类 LocalDate方法介绍 now() : 从默认时 ...
- JDBC的数据类型
以下内容引用自http://wiki.jikexueyuan.com/project/jdbc/data-types.html: JDBC驱动程序在将Java数据类型发送到数据库之前,会将其转换为相应 ...
- Nginx/Spring:增加上传文件尺寸限制
Nginx: 1. vi /etc/nginx/nginx.config 2. 在server中增加如下行 # set client body size to 20M # client_max_bod ...
- 网易互娱2017实习生招聘游戏研发工程师在线笔试第二场 C
偶尔碰到这题,简单数位DP题,然而我已生疏了…… 这次算是重新想到的,看来对DP的理解有增进了…… dp[i][j][k],表示前i为,mod为j,是否出现2.3.5的剩下的数位可组成的数字.答案就是 ...
- 009 NAT
static nat r1(config)#ip nat inside source static 192.168.1.2 10.0.0.2 r1(config)#int f0/0 r1(config ...