简单数学 19056

19056 简单数学

时间限制:1000MS  代码长度限制:10KB
提交次数:0 通过次数:0

题型: 编程题   语言: 不限定

Description

在一个平面直角坐标系中,给出n个一元一次方程组,y=kx+b,k,b为非负整数,小明希望算出至少p条直线的y值>=m时,
最小的正整数x为多少?



 

输入格式

输入为多case
第一行为一个T
表示数据组数,每组数据第一行包括三个整数n,p,m,表示方程的个数,最少要有多少条直线,y值需要大于等于多少。
接着是n行,每行有一个k和b
1<=p<=n<=10^5
0<=k<=10^3
0<=b<=10^9
1<=m<=10^9


 

输出格式

每组数据输出一行,表示最小的正整数x,数据保证有答案。


 

输入样例

1
2 1 5
2 2
2 3


 

输出样例

1

#include <iostream>
#include <cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<utility>
#include<set>
#include<cstring>
#include<map>
typedef long long ll;
using namespace std;
vector<double>ans;
int main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
    ll t;
    cin>>t;
    while(t--){
       ans.clear();
       ll n,p,m;
       cin>>n>>p>>m;
       for(int i=0;i<n;i++){
        double k,b;
        cin>>k>>b;
        if(k==0){
            if(b>=m)p--;
            //当斜率为0 的时候,b>m才可以有一条直线符合条件
            //否则无效
        }else{
            //k!=0时
            double res = (m-b)/(double)k;
            ans.push_back(res);
        }
       }
       if(ans.size())sort(ans.begin(),ans.end());
       if(p<=0)cout<<1<<endl;
       else{
           double res = ans[p-1];
            if(res<=1)cout<<1<<endl;
            else {
                int tres;
                if(res == (int)res)tres = (int)res;
                else tres = (int)res+1;
                cout<<tres<<endl;
            }
       }

    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值