zoukankan      html  css  js  c++  java
  • $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 ;
    }
    
  • 相关阅读:
    android.animation(6)
    android.animation(5)
    android.animation(4)
    android.animation(3)
    android.animation(2)
    android.animation(1)
    android.view.animation(2)
    php热身2:CRUD with Ajax
    PHP热身
    Android热身:通过网络获取资源并更新UI组件
  • 原文地址:https://www.cnblogs.com/qf-breeze/p/10735878.html
Copyright © 2011-2022 走看看