$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 ;
}
随机推荐
- 怎样签发SSL证书
最近在做怎样让网站有SSL,搞了一天,现在总结一下 首先要安装OPENSSL和 Java的 keytool 先用OPENSSL生成私钥和CSR openssl req -newkey rsa:2048 ...
- j简单的分类实现-K近邻
dataSetSize=dataSet.shape[0] voteIlabel=labels[sortedDistIndicies[i]] ...
- [cf360 div1.C]The Values You Can Make[Dp]
题意:有n个硬币,面值不同,求能组成K的方案中,每个方案的硬币可以凑成那些答案. 例如, K=5 面值={1,1,1,2,3} K={1,1,1,2} K={1,1,3} K={2,3} 那么答案是 ...
- linux 用户管理、权限管理
1.useradd -[ugGdsce]2.passwd 用户名 ================================================ 1.chmod 2.chown 3. ...
- HDU 5644 King's Pliot【费用流】
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5644 题意: 每天都有p[i]个飞行员进行阅兵,飞行员只工作一天. m个休假公式,花费tt[i]元让 ...
- AOJ731(不等式)
题意:有n(n<=100)个石头,每个石头的价值在Ai~Bi(1<=Ai<=Bi<=10000)之间,将这些石头分给两个人,求两个人的最大总价值差的最小值 分析: 与一般的求最 ...
- ArcGIS Engine效率探究——要素的添加和删除、属性的读取和更新
ArcGIS Engine效率探究——要素的添加和删除.属性的读取和更新 来自:http://blog.csdn.net/freewaywalker/article/details/23703863 ...
- Linux学习系列之LNMP
LNMP介绍 LNMP是什么 LNMP(Linux-Nginx-MySQL-PHP)网站架构是目前国际流行的Web架构; 这四种软件组合,可以成为一个免费.高效.扩展性强的Web架构; LNMP原理图 ...
- day03-hdfs的客户端操作\hdfs的java客户端编程
5.hdfs的客户端操作 客户端的理解 hdfs的客户端有多种形式: 1.网页形式 2.命令行形式 3.客户端在哪里运行,没有约束,只要运行客户端的机器能够跟hdfs集群联网 文件的切块大小和存储的副 ...
- 异 形 卵 709 南阳oj
http://acm.nyist.net/JudgeOnline/problem.php? pid=709 异 形 卵 时间限制:1000 ms | 内存限制:65535 KB 难度: 描写叙述 ...