1 条题解

  • 0
    @ 2025-8-24 21:32:52

    自动搬运

    查看原文

    来自洛谷,原作者为

    avatar liao
    **

    搬运于2025-08-24 21:32:52,当前版本为作者最后更新于2019-02-17 22:38:06,作者可能在搬运后再次修改,您可在原文处查看最新版

    自动搬运只会搬运当前题目点赞数最高的题解,您可前往洛谷题解查看更多

    以下是正文


    先前好像有点排版错误,这里更正一下 qwq

    这题好坑啊

    看似很简单,但是,我竟然挂了两次~~(好丢脸啊)~~,

    前往博客食用效果更佳

    -------------------- 我是分割线 --------------------

    • 第一次提交:怎么会RE?!竟然有除以0的情况!!
    //RE Code
    #include<bits/stdc++.h>
    using namespace std;
    int tot,num,bld,cst,hrt,flg;
    int main() {
    		cin>>tot>>num>>bld;
    		for(int i=1; i<=num; i++) {
    			cin>>cst>>hrt;
    			if((tot/cst)*hrt>=bld)
    				flg=1,cout<<i<<' ';
    		}
    		if(!flg)cout<<-1;
    		return 0;
    }
    
    • 第二次:WA??哇!花费0,技能伤害为正数为可以击败boos
    //WA Code
    #include<bits/stdc++.h>
    using namespace std;
    int tot,num,bld,cst,hrt,flg;
    int main() {
    		cin>>tot>>num>>bld;
    		for(int i=1; i<=num; i++) {
    			cin>>cst>>hrt;
    			if(cst&&(tot/cst)*hrt>=bld)
    				flg=1,cout<<i<<' ';
    		}
    		if(!flg)cout<<-1;
    		return 0;
    }
    
    • 嘿嘿嘿——我最喜欢绿色了
    //AC Code!!
    #include<bits/stdc++.h>
    using namespace std;
    int tot,num,bld,cst,hrt,flg;
    int main() {
    		cin>>tot>>num>>bld;
    		for(int i=1; i<=num; i++) {
    			cin>>cst>>hrt;
    			if((!cst&&hrt)||(cst&&(tot/cst)*hrt>=bld))
    				flg=1,cout<<i<<' ';
    		}
    		if(!flg)cout<<-1;
    		return 0;//代码是不是很清爽呢
    }
    

    卖个萌(╹▽╹),求过

    • 1

    信息

    ID
    971
    时间
    1000ms
    内存
    125MiB
    难度
    1
    标签
    递交数
    1
    已通过
    1
    上传者