結果
問題 | No.3018 目隠し宝探し |
ユーザー |
|
提出日時 | 2025-01-25 14:42:17 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 227 ms / 2,000 ms |
コード長 | 1,034 bytes |
コンパイル時間 | 4,466 ms |
コンパイル使用メモリ | 80,732 KB |
実行使用メモリ | 61,048 KB |
平均クエリ数 | 2.68 |
最終ジャッジ日時 | 2025-01-25 23:27:46 |
合計ジャッジ時間 | 10,253 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 21 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int w = sc.nextInt(); if(h * w == 1) { System.out.println("! 1 1"); return; }if(h == 1) { System.out.println("? " + 1 + " " + 1); int p1 = sc.nextInt(); System.out.println("! " + 1 + " " + (1 + (int)Math.sqrt(p1))); return; }if(w == 1) { System.out.println("? " + 1 + " " + 1); int p1 = sc.nextInt(); System.out.println("! " + (1 + (int)Math.sqrt(p1)) + " " + 1); return; } System.out.println("? " + 1 + " " + 1); int p1 = sc.nextInt(); System.out.println("? " + h + " " + 1); int p2 = sc.nextInt(); for(int i = 1;i <= h;i++) { for(int j = 1;j <= w;j++) { int sub1 = (1 - i) * (1 - i) + (1 - j) * (1 - j); int sub2 = (h - i) * (h - i) + (1 - j) * (1 - j); if(sub1 == p1 && sub2 == p2) { System.out.println("! " + i + " " + j); return; } } } } }