0

1 Test case failed

My code is : import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String s = in.nextLine(); int d=Integer.parseInt(in.nextLine()); String name=in.nextLine(); in.close(); String names[] = name.split(" "); int k = 0; if(names.length+1<=d) System.out.println("20"); else { for (int i = 0; i < names.length; i++) { if (s.compareTo(names[i]) > 0) k++; } int t = k; int a = 0; if (t % 2 == 0) a = 1; while (t > d) { t = t - d; a++; } if (k < d) System.out.println("20"); else System.out.println((20 + a * 20)); } } } Please help as i could not find where it is failing.

2nd Apr 2020, 8:04 AM
Ashish Kumar
Ashish Kumar - avatar
2 Respuestas
0
Change (t % 2) to (t % d) at the if statement
2nd Apr 2020, 8:22 AM
你知道規則,我也是
你知道規則,我也是 - avatar
0
Thanks CarrieForle It worked.
2nd Apr 2020, 8:35 AM
Ashish Kumar
Ashish Kumar - avatar