题解 | 买橘子

买橘子

https://www.nowcoder.com/practice/73e0552b78474a9086781e47f4e01d73

#include <iostream>
using namespace std;

int main() {
    int n;
    cin>>n;//6x+8y=n
    if(n%2!=0||n<6)cout<<"-1"<<endl;
    for(int i=n/8;i>=0;i--){
        if(n%8==0){ cout<<i<<endl;}
       else{
        int x=n-i*8;
        if(x%6==0&&x>=6){cout<<x/6+i<<endl;   return 0;}
       
    }    
 }    
      

}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

不知道怎么取名字_:现在找工作是真的太不容易了
点赞 评论 收藏
分享
最喜欢秋天的火龙果很...:第一份工作一定要往大的去,工资低点没事。后面换工作会更好找,即使你去小公司,你也不可能不会换工作的。所以找大的去
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务