$CF1153A\ Serval\ and\ Bus$
2024-08-30 20:37:14
看大佬的代码都好复杂(不愧是大佬\(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 ;
}
最新文章
- 搭建TFS 2015 Build Agent环境(一)
- 采用dom4j和反射模拟Spring框架的依赖注入功能
- CI3.0控制器下面建文件夹 访问一直404 的解决方法
- 股票数据调用示例代码php
- The Triumph Of Bio-logic
- pl/sql developer——instant-client 简单配置
- delphi 基础之三 文件流操作
- margin的重叠现象
- Bash shell 笔记总结(一) 转自http://www.bubuko.com/infodetail-509992.html,谢谢原作者
- vsftpd安装
- PAT (Advanced Level) 1114. Family Property (25)
- 使用Compute Shader加速Irradiance Environment Map的计算
- 编写自己的一个简单的web容器(二)
- AM335x(TQ335x)学习笔记——Nand&;&;网卡驱动移植
- 自定义EL函数(以将字母转为大写为例)
- django 图书管理系统
- FileSync文件同步更新工具
- Java Spring+Mysql+Mybatis 实现用户登录注册功能
- Python2.7-内置异常类型
- JFreeChart 之饼图
热门文章
- bzoj 2588 Spoj 10628. Count on a tree (可持久化线段树)
- Mybatis教程(一)
- 选择器的使用(not选择器)
- Array.prototype.map()方法详解
- mysql导入大型sql文件时注意事项
- UVa 340 Master-Mind Hints(猜数字游戏的提示)
- Linux命令输出头(标题)、输出结果排序技巧
- FTP Server完整篇 ubuntu 10.04
- HDU 5319 Painter(枚举)
- Jquery第四课 Javascript中this的使用方法