結果
問題 | No.321 (P,Q)-サンタと街の子供たち |
ユーザー |
|
提出日時 | 2015-12-15 02:32:44 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 282 ms / 2,000 ms |
コード長 | 815 bytes |
コンパイル時間 | 54 ms |
コンパイル使用メモリ | 7,680 KB |
実行使用メモリ | 12,672 KB |
最終ジャッジ日時 | 2024-07-06 22:02:23 |
合計ジャッジ時間 | 7,762 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 |
コンパイルメッセージ
Syntax OK
ソースコード
#! ruby# yukicoder My Practice# author: Leonardone @ NEETSDKASUdef gs(); gets.chomp; enddef gi(); gets.to_i; enddef gss(); gets.chomp.split; enddef gis(); gss.map(&:to_i); end# 解説読後# http://yukicoder.me/problems/849/editorialP, Q = gisN = gig = P * Q == 0 ? 1 : P.gcd(Q)pg = P / gqg = Q / gc = 0N.times dox, y = gis.map(&:abs)if x == 0 && y == 0c += 1nextendif P == 0c += 1 if Q > 0 && x % Q == 0 && y % Q == 0nextendif Q == 0c += 1 if x % P == 0 && y % P == 0nextendnext if x % g > 0 || y % g > 0x /= gy /= gu, v = [x % 2, y % 2].minmaxif u == 0 && v == 1c += 1 if pg % 2 == 0 || qg % 2 == 0elsec += 1endendp c