From 1bfc6d4f89e08a72ee048290210e273fc1833840 Mon Sep 17 00:00:00 2001 From: kurisu Date: Wed, 2 Jul 2025 15:31:18 +0900 Subject: [PATCH 1/4] =?UTF-8?q?paizaC116=E3=81=AE=E5=9B=9E=E7=AD=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kurisu/src/C116.java | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 kurisu/src/C116.java diff --git a/kurisu/src/C116.java b/kurisu/src/C116.java new file mode 100644 index 0000000..f646c58 --- /dev/null +++ b/kurisu/src/C116.java @@ -0,0 +1,56 @@ +import java.util.Scanner; + +class Checkstick { + private int consectivemark = 0; + private boolean wrongflag = false; + + Checkstick() {} + + // 外れ棒の連続回数が指定回数より上回ればフラグをtrue、それ以外はfalseを返す + boolean inspectionStick(int stick, int wrongrod, Scanner sc) { + for (int i = 0; i < stick; i++) { + int stickresult = sc.nextInt(); + + if (consectivemark < wrongrod) { + // 外れが連続すればカウントしていく + if (stickresult == 0) { + consectivemark++; + // 連続が途切れた場合カウントを最初からやり直す + } else if (stickresult != 0) { + consectivemark = 0; + } + } + if (consectivemark >= wrongrod) { + wrongflag = true; + } + } + return wrongflag; + } +} + + +class Showresult { + Showresult() {} + + void resultShow(boolean inspectresult) { + if (inspectresult == true) { + System.out.println("NG"); + } else { + System.out.println("OK"); + } + } +} + + +public class C116 { + public static void main(String[] args) throws Exception { + Scanner sc = new Scanner(System.in); + final int icestick = sc.nextInt(); + final int wrongrod = sc.nextInt(); + Checkstick resultflag = new Checkstick(); + final boolean inspectresult = resultflag.inspectionStick(icestick, wrongrod, sc); + Showresult losecontinuous = new Showresult(); + losecontinuous.resultShow(inspectresult); + sc.close(); + } +} -- GitLab From e39f69e8fd20bade6bf2823c5a08dea52e09b373 Mon Sep 17 00:00:00 2001 From: kurisu Date: Thu, 3 Jul 2025 13:32:15 +0900 Subject: [PATCH 2/4] =?UTF-8?q?paiza=20C116=E3=81=AE=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kurisu/src/C116.java | 61 +++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/kurisu/src/C116.java b/kurisu/src/C116.java index f646c58..d8e3102 100644 --- a/kurisu/src/C116.java +++ b/kurisu/src/C116.java @@ -1,56 +1,53 @@ import java.util.Scanner; -class Checkstick { - private int consectivemark = 0; - private boolean wrongflag = false; +public class C116 { + public static void main(String[] args) throws Exception { + Scanner sc = new Scanner(System.in); + final int allStick = sc.nextInt(); + final int checkRange = sc.nextInt(); + CheckStick resultFlag = new CheckStick(); + final boolean inspectResult = resultFlag.isInspectionStick(allStick, checkRange, sc); + ShowResult result = new ShowResult(); + result.outputResult(inspectResult); + sc.close(); + } +} - Checkstick() {} + +class CheckStick { // 外れ棒の連続回数が指定回数より上回ればフラグをtrue、それ以外はfalseを返す - boolean inspectionStick(int stick, int wrongrod, Scanner sc) { + boolean isInspectionStick(final int stick, final int checkRange, final Scanner sc) { + int consectiveMark = 0; + boolean wrongFlag = false; for (int i = 0; i < stick; i++) { - int stickresult = sc.nextInt(); + int stickResult = sc.nextInt(); - if (consectivemark < wrongrod) { + if (consectiveMark < checkRange) { // 外れが連続すればカウントしていく - if (stickresult == 0) { - consectivemark++; + if (stickResult == 0) { + consectiveMark++; // 連続が途切れた場合カウントを最初からやり直す - } else if (stickresult != 0) { - consectivemark = 0; + } else { + consectiveMark = 0; } } - if (consectivemark >= wrongrod) { - wrongflag = true; + if (consectiveMark >= checkRange) { + wrongFlag = true; } } - return wrongflag; + return wrongFlag; } } -class Showresult { - Showresult() {} +class ShowResult { - void resultShow(boolean inspectresult) { - if (inspectresult == true) { + void outputResult(final boolean inspectResult) { + if (inspectResult == true) { System.out.println("NG"); } else { System.out.println("OK"); } } } - - -public class C116 { - public static void main(String[] args) throws Exception { - Scanner sc = new Scanner(System.in); - final int icestick = sc.nextInt(); - final int wrongrod = sc.nextInt(); - Checkstick resultflag = new Checkstick(); - final boolean inspectresult = resultflag.inspectionStick(icestick, wrongrod, sc); - Showresult losecontinuous = new Showresult(); - losecontinuous.resultShow(inspectresult); - sc.close(); - } -} -- GitLab From 8e395d7ff3134fa5a2b4cc6ce4f611bab506162d Mon Sep 17 00:00:00 2001 From: kurisu Date: Thu, 3 Jul 2025 15:28:21 +0900 Subject: [PATCH 3/4] =?UTF-8?q?paiza=20C116=E3=81=AE2=E5=9B=9E=E7=9B=AE?= =?UTF-8?q?=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kurisu/src/C116.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kurisu/src/C116.java b/kurisu/src/C116.java index d8e3102..5163169 100644 --- a/kurisu/src/C116.java +++ b/kurisu/src/C116.java @@ -3,12 +3,16 @@ import java.util.Scanner; public class C116 { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); + final int allStick = sc.nextInt(); final int checkRange = sc.nextInt(); + CheckStick resultFlag = new CheckStick(); final boolean inspectResult = resultFlag.isInspectionStick(allStick, checkRange, sc); + ShowResult result = new ShowResult(); result.outputResult(inspectResult); + sc.close(); } } @@ -17,11 +21,12 @@ public class C116 { class CheckStick { // 外れ棒の連続回数が指定回数より上回ればフラグをtrue、それ以外はfalseを返す - boolean isInspectionStick(final int stick, final int checkRange, final Scanner sc) { + final boolean isInspectionStick(final int stick, final int checkRange, final Scanner sc) { int consectiveMark = 0; boolean wrongFlag = false; + for (int i = 0; i < stick; i++) { - int stickResult = sc.nextInt(); + final int stickResult = sc.nextInt(); if (consectiveMark < checkRange) { // 外れが連続すればカウントしていく -- GitLab From dee64ca6ef5053f3cca067c2a366daf7164c3e7d Mon Sep 17 00:00:00 2001 From: kurisu Date: Thu, 3 Jul 2025 17:33:54 +0900 Subject: [PATCH 4/4] =?UTF-8?q?paiza=E3=81=AEC116=E3=81=AE=E4=BF=AE?= =?UTF-8?q?=E6=AD=A33=E5=9B=9E=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kurisu/src/C116.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kurisu/src/C116.java b/kurisu/src/C116.java index 5163169..a265001 100644 --- a/kurisu/src/C116.java +++ b/kurisu/src/C116.java @@ -36,8 +36,7 @@ class CheckStick { } else { consectiveMark = 0; } - } - if (consectiveMark >= checkRange) { + } else { wrongFlag = true; } } -- GitLab