魔法(csdn編程挑戰),魔法csdn編程挑戰

來源:互聯網
上載者:User

魔法(csdn編程挑戰),魔法csdn編程挑戰
魔法題目詳情:

你擁有3種魔法,可以用第一種魔法把 a 克的沙子變成 b 克金屬,可以用第二種魔法把 c 克金屬變成 d 克金子,可以用第三種魔法把 e 克金子變成 f 克沙子。

問你能否用初始有限量的沙子、金屬、金子得到無限多的金子?

輸入格式:

多組資料,每組只有一行包含輸入6個整數 a,b,c,d,e,f

(0<=a,b,c,d,e,f<=1000)

輸出格式:

每組輸出一行,YES和NO表示能否得到無限多的金子。



答題說明:

輸入範例

100 200 250 150 200 250

100 50 50 200 200 100

1 1 0 1 1 1

100 1 100 1 0 1

輸出範例:

YES

NO

YES

YES


需特判為0的情況。

代碼:

#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>int main(){    int a,b,c,d,e,f;    while(~scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f))    {        if(d==0) printf("NO\n");        else if(c==0) printf("YES\n");        else if(b==0) printf("NO\n");        else if(a==0) printf("YES\n");        else if(f==0) printf("NO\n");        else if(e==0) printf("YES\n");        else if(b*d*f>a*c*e) printf("YES\n");        else printf("NO\n");    }}


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.