From 9109a45600cfe0b51107a12e4c35f356f9631333 Mon Sep 17 00:00:00 2001 From: kshiraishi Date: Mon, 30 Jun 2025 16:30:41 +0900 Subject: [PATCH 1/2] =?UTF-8?q?paiza=E3=81=AE=E5=95=8F=E9=A1=8CC=5F148?= =?UTF-8?q?=E3=81=AE=E5=9B=9E=E7=AD=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kshiraishi/README.md | 25 ++++++++++++++++ kshiraishi/src/C148.java | 63 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 kshiraishi/README.md create mode 100644 kshiraishi/src/C148.java diff --git a/kshiraishi/README.md b/kshiraishi/README.md new file mode 100644 index 0000000..3ca94a8 --- /dev/null +++ b/kshiraishi/README.md @@ -0,0 +1,25 @@ +# Paiza + +新人研修用のPaizaレビュー用プロジェクト + +### 命名規則 +- クラス名の先頭に難易度と問題番号を記載する +> ex) 難易度Bの問題番号1の場合、B001_{適当なクラス名}.java + +### レビュー依頼方法 +個人名を含む適当なブランチを作成し、mainブランチへのMRを作成することでレビューを依頼する。 + + + +1. MRを作成する際は命名規則と同様にタイトルに難易度と問題番号を記載し、その後ろに日本語で簡単な説明を記載する。 +> ex) B108 観覧車の稼働状況 + +2. Descriptionの部分に問題、入力される値、期待する出力、条件、結果がわかる画像を添付する +3. 各曜日のレビュー担当者をAssigneeに設定し、MRを作成する +4. SlackでMRのリンクとともに担当者にメンションし、レビューを依頼する + + +##### ディレクトリ構成 +- {個人ネームフォルダ} + - src 作成した各種ソース + - test 対応するテストクラス diff --git a/kshiraishi/src/C148.java b/kshiraishi/src/C148.java new file mode 100644 index 0000000..b00e0be --- /dev/null +++ b/kshiraishi/src/C148.java @@ -0,0 +1,63 @@ + + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +public class C148 { + + public static void main(String[] args) { + // 初期化(対戦回数,初期レベル,相手のレベル) + Scanner sc = new Scanner(System.in); + int N, L; + N = sc.nextInt(); + L = sc.nextInt(); + List list = new ArrayList(); + + for (int i = 0; i < N; i++) { + list.add(sc.nextInt()); + } + if(variable_criteria(N, L, list) == false) { + System.out.println("適切な値ではありません"); + System.exit(0); + } + sc.close(); + + // 対戦処理 + for (int i = 0; i < N; i++) { + L = Battle(L, i, list); + } + + // 結果表示 + System.out.println(L); + + } + + // 対戦処理 + public static int Battle(int L, int i, List list) { + if (L > list.get(i)) { + L += list.get(i) / 2; + } else if (L < list.get(i)) { + L = L / 2; + } else { + return L; + } + return L; + } + //変数条件の確認 + public static boolean variable_criteria(int N, int L, List list) { + if(1 > N || 100000 < N) { + return false; + } + if(1 > L || 10000 < L) { + return false; + } + if(1 > list.size() || 100000 < list.size()) { + return false; + } + if(1 > list.size() || list.size() < N) { + return false; + } + return true; + } +} -- GitLab From 548b3477afe95b41f8b0f3250544c6a0130895e7 Mon Sep 17 00:00:00 2001 From: kshiraishi Date: Tue, 1 Jul 2025 14:14:01 +0900 Subject: [PATCH 2/2] =?UTF-8?q?C148=E3=81=AE=E4=BF=AE=E6=AD=A3ver2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kshiraishi/src/C148.java | 65 ++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/kshiraishi/src/C148.java b/kshiraishi/src/C148.java index b00e0be..c3f92c7 100644 --- a/kshiraishi/src/C148.java +++ b/kshiraishi/src/C148.java @@ -1,63 +1,50 @@ - import java.util.ArrayList; import java.util.List; import java.util.Scanner; +/** + * 自身と敵とのレベルを比較し、レベルの変更を行うバトル処理を行う + * + * @author kshiraishi + * @version 2 + * + * @param times 対戦回数 + * @param myLevel 初期レベル + * @param enemyLevel 敵のレベルリスト + */ public class C148 { public static void main(String[] args) { - // 初期化(対戦回数,初期レベル,相手のレベル) + // 初期化 Scanner sc = new Scanner(System.in); - int N, L; - N = sc.nextInt(); - L = sc.nextInt(); - List list = new ArrayList(); + int times, myLevel; + times = sc.nextInt(); + myLevel = sc.nextInt(); + ArrayList enemyLevel = new ArrayList(); - for (int i = 0; i < N; i++) { - list.add(sc.nextInt()); - } - if(variable_criteria(N, L, list) == false) { - System.out.println("適切な値ではありません"); - System.exit(0); + for (int i = 0; i < times; i++) { + enemyLevel.add(sc.nextInt()); } sc.close(); // 対戦処理 - for (int i = 0; i < N; i++) { - L = Battle(L, i, list); + for (int i = 0; i < times; i++) { + myLevel = processBattle(myLevel, i, enemyLevel); } // 結果表示 - System.out.println(L); + System.out.println(myLevel); } // 対戦処理 - public static int Battle(int L, int i, List list) { - if (L > list.get(i)) { - L += list.get(i) / 2; - } else if (L < list.get(i)) { - L = L / 2; - } else { - return L; - } - return L; - } - //変数条件の確認 - public static boolean variable_criteria(int N, int L, List list) { - if(1 > N || 100000 < N) { - return false; - } - if(1 > L || 10000 < L) { - return false; - } - if(1 > list.size() || 100000 < list.size()) { - return false; - } - if(1 > list.size() || list.size() < N) { - return false; + public static int processBattle(int myLevel, int i, List enemyLevel) { + if (myLevel > enemyLevel.get(i)) { + myLevel += enemyLevel.get(i) / 2; + } else if (myLevel < enemyLevel.get(i)) { + myLevel /= 2; } - return true; + return myLevel; } } -- GitLab