Okay, how did you solve the problem?
The naive or straightforward or brute force way of solving this problem
is to actually take all of these numbers, multiply them together, divide that answer by 5,
and see what the remainder is. If the remainder is 0, then it is divisible by 5.
Otherwise, it's not. But you would be very silly to go through that.
What you should do is realize that a product is going to be divisible by 5
if and only if one of the number that you're multiplying into the product is divisible by 5.
And a number is divisible by 5 if and only if its last digit is a 0 or a 5.
What you can do now, instead of actually doing any multiplying,
you just scan your eyes down the columns here and notice that most of them are not 0s or 5s,
but if you're eagle-eyed, you would have noticed this.
There's one number in there that's divisible by 5--945--
and that's all it takes. The whole product is now going to be divisible by 5.
The answer we're looking for is yes. The product is divisible by 5. Ta da!
どのように解きましたか?
単純な直球勝負のアルゴリズムを使うなら
すべての数字を実際にかけ合わせて その結果を5で割ることになります
余りが0なら"5で割り切れる"が答えとなりますが
実際にそんな計算はしたくありません
ポイントは 積が5で割り切れるための必要十分条件は
かける数字の1つが 5で割り切れるものであるということです
またある数字が5で割り切れるための必要十分条件は 下1桁の数字が0か5であるということを使えば
実際の計算は不要です
数字を縦に見ていくと ほとんどは下1桁が0か5ではありませんが
よく観察すればこれに気づいたでしょう
5で割り切れる945があります
これですべての積が5で割り切れることになります
つまり積は5で割り切れるので答えはイエスです いかがでしょうか
Bine, cum ai rezolvat problema?
Modul de rezolvare naiv sau fara complicatii sau de forta majora
inseamna de fapt sa iei toate aceste numere, sa le inmultesti, sa imparti raspunsul la 5
si sa vezi ce rest ramane. Daca restul este 0, atunci rezultatul este divizibil cu 5.
Altfel, acesta nu este divizibil cu 5. Dar ar fi foarte stupid sa faci acest lucru.
Ce ar trebui sa faci este sa-ti dai seama ca un produs va fi divizibil prin 5
daca si numai daca un numar din numerele pe care le inmultesti este divizibil cu 5.
Si un numar este divizibil prin 5 daca si numai daca ultima sa cifra este 0 sau 5.
Ce poti sa faci acum, in loc sa faci vreo inmultire,
trebuie doar sa scanezi din privire coloanele si sa observi ca majoritatea lor nu contin 0 sau 5,
dar daca ai ochi de vultur-, ar fi trebuit sa observi acest lucru.
Exista un numar care este divizibil prin 5--945--
si acest lucru este tot ce trebuie. Intregul produs va fi acum divizibil prin 5.
Raspunsul pe care il cautam este da. Produsul acestor numere este divizibil prin 5. Ta da!