結果
問題 | No.82 市松模様 |
ユーザー |
|
提出日時 | 2017-10-31 22:56:31 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 139 ms / 5,000 ms |
コード長 | 730 bytes |
コンパイル時間 | 3,590 ms |
コンパイル使用メモリ | 74,796 KB |
実行使用メモリ | 41,564 KB |
最終ジャッジ日時 | 2024-11-22 11:15:22 |
合計ジャッジ時間 | 5,642 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 |
ソースコード
import java.util.Scanner;public class No82 {public static void main(String[] args) {Scanner s = new Scanner(System.in);int width = s.nextInt();int height = s.nextInt();String color1 = s.next();String color2 = color1.equals("B") ? "W" : "B";StringBuilder sb = new StringBuilder();for (int i = 0; i < height; i++) {for (int j = 0; j < width; j++) {if (i % 2 == 0 && j % 2 == 0 || i % 2 == 1 && j % 2 == 1) {sb.append(color1);} else {sb.append(color2);}}sb.append("\n");}System.out.print(sb.toString());}}