QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#78134 | #2919. Subprime | bubble_t | WA | 151ms | 39488kb | Java8 | 998b | 2023-02-17 04:49:59 | 2023-02-17 04:50:00 |
Judging History
answer
import java.util.ArrayList;
import java.util.Scanner;
public class Subprime
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int l = sc.nextInt();
int h = sc.nextInt();
String substr = sc.next();
int count = 0;
ArrayList<Integer> prime = new ArrayList<>();
prime.add(2);
int num = 3;
while (prime.size() < h) {
boolean isPrime = true;
int i = 0;
int check = prime.get(i);
while (check < Math.sqrt(num)) {
if (num % check == 0) {
isPrime = false;
break;
}
i++;
check = prime.get(i);
}
if (isPrime == true) {
prime.add(num);
}
num += 2;
}
for (int i = l - 1 ; i < prime.size() ; i++) {
int temp = prime.get(i);
String pstr = Integer.toString(temp);
if (pstr.contains(substr)) {
System.out.println(i + " " + pstr);
count++;
}
}
sc.close();
System.out.println(count);
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 151ms
memory: 39488kb
input:
1 10000 389
output:
83 389 368 2389 491 3389 853 6389 1073 8389 1714 14389 2030 17389 2335 20389 2692 23893 2693 23899 3230 29389 3321 30389 3670 33893 3901 36389 4141 38903 4142 38917 4143 38921 4144 38923 4145 38933 4146 38953 4147 38959 4148 38971 4149 38977 4150 38993 4375 41389 4612 43891 4662 44389 4754 45389 493...
result:
wrong answer 1st lines differ - expected: '45', found: '83 389'