結果
問題 |
No.8 N言っちゃダメゲーム
|
ユーザー |
![]() |
提出日時 | 2025-09-05 08:53:36 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 63 ms / 5,000 ms |
コード長 | 2,179 bytes |
コンパイル時間 | 3,788 ms |
コンパイル使用メモリ | 79,432 KB |
実行使用メモリ | 43,424 KB |
最終ジャッジ日時 | 2025-09-05 08:53:41 |
合計ジャッジ時間 | 5,466 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
ソースコード
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Reader fr = new Reader(); PrintWriter pw = new PrintWriter(System.out); int p = fr.nextInt(); while (p-- > 0) { int n = fr.nextInt(); int k = fr.nextInt(); // Fast modulo using subtraction instead of division int temp = n - 1; int divisor = k + 1; if (temp < divisor) { pw.println(temp == 0 ? "Lose" : "Win"); } else { // Manual modulo calculation while (temp >= divisor) { temp -= divisor; } pw.println(temp == 0 ? "Lose" : "Win"); } } pw.flush(); pw.close(); } // Custom ultra-fast input reader static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public int nextInt() throws IOException { int ret = 0; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); return neg ? -ret : ret; } private void fillBuffer() throws IOException { bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); if (bytesRead == -1) buffer[0] = -1; } private byte read() throws IOException { if (bufferPointer == bytesRead) fillBuffer(); return buffer[bufferPointer++]; } public void close() throws IOException { if (din != null) din.close(); } } }