A prime is a positive integer X that has exactly two distinct divisors: 1 and X. The first few prime integers are 2, 3, 5, 7, 11 and 13.
A semiprime is a natural number that is the product of two (not necessarily distinct) prime numbers. The first few semiprimes are 4, 6, 9, 10, 14, 15, 21, 22, 25, 26.
You are given two non-empty arrays P and Q, each consisting of M integers. These arrays represent queries about the number of semiprimes within specified ranges.
Query K requires you to find the number of semiprimes within the range (P[K], Q[K]), where 1 ≤ P[K] ≤ Q[K] ≤ N.
For example, consider an integer N = 26 and arrays P, Q such that:
P[0] = 1 Q[0] = 26 P[1] = 4 Q[1] = 10 P[2] = 16 Q[2] = 20The number of semiprimes within each of these ranges is as follows:
- (1, 26) is 10,
- (4, 10) is 4,
- (16, 20) is 0.
Write a function:
class Solution { public int[] solution(int N, int[] P, int[] Q); }
that, given an integer N and two non-empty arrays P and Q consisting of M integers, returns an array consisting of M elements specifying the consecutive answers to all the queries.
For example, given an integer N = 26 and arrays P, Q such that:
P[0] = 1 Q[0] = 26 P[1] = 4 Q[1] = 10 P[2] = 16 Q[2] = 20the function should return the values [10, 4, 0], as explained above.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [1..50,000];
- M is an integer within the range [1..30,000];
- each element of arrays P and Q is an integer within the range [1..N];
- P[i] ≤ Q[i].
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[500]
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
for(int i=2; i<)
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
for(int i=2; i<array.length; i++){
for(int j=1;j)
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
for(int i=2; i<array.length; i++){
int j=1;
while
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
for(int i=2; i<array.length; i++){
int j=1;
while(i*j)
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
for(int i=2; i<array.length; i++){
int j=1;
while(i*j<=)
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
for(int i=2; i<array.length; i++){
int j=1;
while(i*j <)
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
for(int i=2; i<array.length; i++){
int j=1;
while(i*j <=)
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
for(int i=2; i<array.length; i++){
int j=1;
while(i*j <=array.length){
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
for(int i=2; i<array.length; i++){
int j=2;
while(i*j <=array.length){
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
for(int i=2; i<array.length; i++){
for()
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if()
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{0};
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array)
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{0};
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == )
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{0};
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
return;
}
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{0};
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
return;
}
array[]
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{0};
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
return;
}
array[i*j]=1;
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{0};
array[1]=
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
return;
}
array[i*j]=1;
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{0};
array[1]=1;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
return;
}
array[i*j]=1;
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{0};
array[1]=1;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
return;
}
array[i*j]=1;
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{0};
array[1]=1;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
return;
}
if()
array[i*j]=1;
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{0};
array[1]=1;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
return;
}
if(i)
array[i*j]=1;
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{0};
array[1]=1;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
return;
}
if(array[i] == )
array[i*j]=1;
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{0};
array[1]=1;
cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
return;
}
if(array[i] == 0 && array[j] == 0){
cmt
array[]
}
array[i*j]=1;
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{0};
array[1]=1;
cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
return;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
array[i*j]
}
array[i*j]=1;
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{0};
array[1]=1;
cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
return;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
array[i*j]=2;
}else{
array[i*j]=1;
}
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{0};
array[1]=1;
cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
return;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}else{
array[i*j]=1;
}
}
}
}
}
Solution.java:10: error: ';' expected int[] array = new int[50000]{0}; ^ Solution.java:10: error: not a statement int[] array = new int[50000]{0}; ^ Solution.java:10: error: ';' expected int[] array = new int[50000]{0}; ^ 3 errors
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000]{;
array[1]=1;
cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
return;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}else{
array[i*j]=1;
}
}
}
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
return;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}else{
array[i*j]=1;
}
}
}
}
}
Solution.java:12: error: cannot find symbol cnt = 0; ^ symbol: variable cnt location: class Solution Solution.java:16: error: incompatible types: missing return value return; ^ Solution.java:19: error: cannot find symbol ++cnt; ^ symbol: variable cnt location: class Solution 3 errors
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
break;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}else{
array[i*j]=1;
}
}
}
}
}
Solution.java:12: error: cannot find symbol cnt = 0; ^ symbol: variable cnt location: class Solution Solution.java:19: error: cannot find symbol ++cnt; ^ symbol: variable cnt location: class Solution 2 errors
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
break;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}else{
array[i*j]=1;
}
}
}
}
}
Solution.java:27: error: missing return statement } ^ 1 error
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
break;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}else{
array[i*j]=1;
}
}
}
tr
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 1){
break;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}else{
array[i*j]=1;
}
}
}
return array;
}
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 50000 at Solution.solution(Solution.java:21) at Exec.run(exec.java:50) at Exec.main(exec.java:36)stdout:
4 6 10 14 18 22 26 30 32 34 38 42 46 48 50 54 58 62 66 70 74 78 80 82 86 90 94 98 102 106 110 112 114 118 122 126 130 134 138 142 144 146 150 154 158 162 166 170 174 176 178 182 186 190 194 198 202 206 208 210 214 218 222 226 230 234 238 240 242 246 250 254 256 258 262 266 270 272 274 278 282 286 290 294 298 302 304 306 310 314 318 322 326 330 334 336 338 342 346 350 354 358 362 366 368 370 374 378 382 384 386 390 394 398 400 402 406 410 414 418 422 426 430 432 434 438 442 446 450 454 458 462 464 466 470 474 478 482 486 490 494 496 498 502 506 510 514 518 522 526 528 530 534 538 542 546 550 554 558 560 562 566 570 574 578 582 586 590 592 594 598 602 606 610 614 618 622 624 626 630 634 638 640 642 646 650 654 656 658 662 666 670 674 678 682 686 688 690 694 698 702 706 710 714 718 720 722 726 730 734 738 742 746 750 752 754 758 762 766 770 774 778 782 784 786 790 794 798 802 806 810 814 816 818 822 826 830 834 838 842 846 848 850 854 858 862 866 870 874 878 880 882 886 890 894 896 898 902 906 910 912 914 918 922 926 930 934 938 942 944 946 950 954 958 962 966 970 974 976 978 982 986 990 994 998 1002 1006 1008 1010 1014 1018 1022 1026 1030 1034 1038 1040 1042 1046 1050 1054 1058 1062 1066 1070 1072 1074 1078 1082 1086 1090 1094 1098 1102 1104 1106 1110 1114 1118 1122 1126 1130 1134 1136 1138 1142 1146 1150 1152 1154 1158 1162 1166 1168 1170 1174 1178 1182 1186 1190 1194 1198 1200 1202 1206 1210 1214 1218 1222 1226 1230 1232 1234 1238 1242 1246 1250 1254 1258 1262 1264 1266 1270 1274 1278 1282 1286 1290 1294 1296 1298 1302 1306 1310 1314 1318 1322 1326 1328 1330 1334 1338 1342 1346 1350 1354 1358 1360 1362 1366 1370 1374 1378 1382 1386 1390 1392 1394 1398 1402 1406 1408 1410 1414 1418 1422 1424 1426 1430 1434 1438 1442 1446 1450 1454 1456 1458 1462 1466 1470 1474 1478 1482 1486 1488 1490 1494 1498 1502 1506 1510 1514 1518 1520 1522 1526 1530 1534 1538 1542 1546 1550 1552 1554 1558 1562 1566 1570 1574 1578 1582 1584 1586 1590 1594 1598 1602 1606 1610 1614 1616 1618 1622 1626 1630 1634 1638 1642 1646 1648 1650 1654 165
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
if(array[i] == 1){
break;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}else{
array[i*j]=1;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; i++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
else if(array[i] == 1){
break;
}
else{
array[i*j]=1;
}
}
}
return array;
}
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 50000 at Solution.solution(Solution.java:18) at Exec.run(exec.java:50) at Exec.main(exec.java:36)stdout:
4 6 10 14 18 22 26 30 32 34 38 42 46 48 50 54 58 62 66 70 74 78 80 82 86 90 94 98 102 106 110 112 114 118 122 126 130 134 138 142 144 146 150 154 158 162 166 170 174 176 178 182 186 190 194 198 202 206 208 210 214 218 222 226 230 234 238 240 242 246 250 254 256 258 262 266 270 272 274 278 282 286 290 294 298 302 304 306 310 314 318 322 326 330 334 336 338 342 346 350 354 358 362 366 368 370 374 378 382 384 386 390 394 398 400 402 406 410 414 418 422 426 430 432 434 438 442 446 450 454 458 462 464 466 470 474 478 482 486 490 494 496 498 502 506 510 514 518 522 526 528 530 534 538 542 546 550 554 558 560 562 566 570 574 578 582 586 590 592 594 598 602 606 610 614 618 622 624 626 630 634 638 640 642 646 650 654 656 658 662 666 670 674 678 682 686 688 690 694 698 702 706 710 714 718 720 722 726 730 734 738 742 746 750 752 754 758 762 766 770 774 778 782 784 786 790 794 798 802 806 810 814 816 818 822 826 830 834 838 842 846 848 850 854 858 862 866 870 874 878 880 882 886 890 894 896 898 902 906 910 912 914 918 922 926 930 934 938 942 944 946 950 954 958 962 966 970 974 976 978 982 986 990 994 998 1002 1006 1008 1010 1014 1018 1022 1026 1030 1034 1038 1040 1042 1046 1050 1054 1058 1062 1066 1070 1072 1074 1078 1082 1086 1090 1094 1098 1102 1104 1106 1110 1114 1118 1122 1126 1130 1134 1136 1138 1142 1146 1150 1152 1154 1158 1162 1166 1168 1170 1174 1178 1182 1186 1190 1194 1198 1200 1202 1206 1210 1214 1218 1222 1226 1230 1232 1234 1238 1242 1246 1250 1254 1258 1262 1264 1266 1270 1274 1278 1282 1286 1290 1294 1296 1298 1302 1306 1310 1314 1318 1322 1326 1328 1330 1334 1338 1342 1346 1350 1354 1358 1360 1362 1366 1370 1374 1378 1382 1386 1390 1392 1394 1398 1402 1406 1408 1410 1414 1418 1422 1424 1426 1430 1434 1438 1442 1446 1450 1454 1456 1458 1462 1466 1470 1474 1478 1482 1486 1488 1490 1494 1498 1502 1506 1510 1514 1518 1520 1522 1526 1530 1534 1538 1542 1546 1550 1552 1554 1558 1562 1566 1570 1574 1578 1582 1584 1586 1590 1594 1598 1602 1606 1610 1614 1616 1618 1622 1626 1630 1634 1638 1642 1646 1648 1650 1654 165
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
else if(array[i] == 1){
break;
}
else{
array[i*j]=1;
}
}
}
return array;
}
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 50000 at Solution.solution(Solution.java:24) at Exec.run(exec.java:50) at Exec.main(exec.java:36)stdout:
4 6 10 14 18 22 26 30 34 38 42 46 50 54 58 62 66 70 74 78 82 86 90 94 98 102 106 110 114 118 122 126 130 134 138 142 146 150 154 158 162 166 170 174 178 182 186 190 194 198 202 206 210 214 218 222 226 230 234 238 242 246 250 254 258 262 266 270 274 278 282 286 290 294 298 302 306 310 314 318 322 326 330 334 338 342 346 350 354 358 362 366 370 374 378 382 386 390 394 398 402 406 410 414 418 422 426 430 434 438 442 446 450 454 458 462 466 470 474 478 482 486 490 494 498 502 506 510 514 518 522 526 530 534 538 542 546 550 554 558 562 566 570 574 578 582 586 590 594 598 602 606 610 614 618 622 626 630 634 638 642 646 650 654 658 662 666 670 674 678 682 686 690 694 698 702 706 710 714 718 722 726 730 734 738 742 746 750 754 758 762 766 770 774 778 782 786 790 794 798 802 806 810 814 818 822 826 830 834 838 842 846 850 854 858 862 866 870 874 878 882 886 890 894 898 902 906 910 914 918 922 926 930 934 938 942 946 950 954 958 962 966 970 974 978 982 986 990 994 998 1002 1006 1010 1014 1018 1022 1026 1030 1034 1038 1042 1046 1050 1054 1058 1062 1066 1070 1074 1078 1082 1086 1090 1094 1098 1102 1106 1110 1114 1118 1122 1126 1130 1134 1138 1142 1146 1150 1154 1158 1162 1166 1170 1174 1178 1182 1186 1190 1194 1198 1202 1206 1210 1214 1218 1222 1226 1230 1234 1238 1242 1246 1250 1254 1258 1262 1266 1270 1274 1278 1282 1286 1290 1294 1298 1302 1306 1310 1314 1318 1322 1326 1330 1334 1338 1342 1346 1350 1354 1358 1362 1366 1370 1374 1378 1382 1386 1390 1394 1398 1402 1406 1410 1414 1418 1422 1426 1430 1434 1438 1442 1446 1450 1454 1458 1462 1466 1470 1474 1478 1482 1486 1490 1494 1498 1502 1506 1510 1514 1518 1522 1526 1530 1534 1538 1542 1546 1550 1554 1558 1562 1566 1570 1574 1578 1582 1586 1590 1594 1598 1602 1606 1610 1614 1618 1622 1626 1630 1634 1638 1642 1646 1650 1654 1658 1662 1666 1670 1674 1678 1682 1686 1690 1694 1698 1702 1706 1710 1714 1718 1722 1726 1730 1734 1738 1742 1746 1750 1754 1758 1762 1766 1770 1774 1778 1782 1786 1790 1794 1798 1802 1806 1810 1814 1818 1822 1826 1830 1834 1838 1842 1846 1850 1854 1858
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
else if(array[i] == 1){
break;
}
else{
array[i*j]=1;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
else{
array[i*j]=1;
}
}
}
return array;
}
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 50000 at Solution.solution(Solution.java:24) at Exec.run(exec.java:50) at Exec.main(exec.java:36)stdout:
4 6 10 14 18 22 26 30 34 38 42 46 50 54 58 62 66 70 74 78 82 86 90 94 98 102 106 110 114 118 122 126 130 134 138 142 146 150 154 158 162 166 170 174 178 182 186 190 194 198 202 206 210 214 218 222 226 230 234 238 242 246 250 254 258 262 266 270 274 278 282 286 290 294 298 302 306 310 314 318 322 326 330 334 338 342 346 350 354 358 362 366 370 374 378 382 386 390 394 398 402 406 410 414 418 422 426 430 434 438 442 446 450 454 458 462 466 470 474 478 482 486 490 494 498 502 506 510 514 518 522 526 530 534 538 542 546 550 554 558 562 566 570 574 578 582 586 590 594 598 602 606 610 614 618 622 626 630 634 638 642 646 650 654 658 662 666 670 674 678 682 686 690 694 698 702 706 710 714 718 722 726 730 734 738 742 746 750 754 758 762 766 770 774 778 782 786 790 794 798 802 806 810 814 818 822 826 830 834 838 842 846 850 854 858 862 866 870 874 878 882 886 890 894 898 902 906 910 914 918 922 926 930 934 938 942 946 950 954 958 962 966 970 974 978 982 986 990 994 998 1002 1006 1010 1014 1018 1022 1026 1030 1034 1038 1042 1046 1050 1054 1058 1062 1066 1070 1074 1078 1082 1086 1090 1094 1098 1102 1106 1110 1114 1118 1122 1126 1130 1134 1138 1142 1146 1150 1154 1158 1162 1166 1170 1174 1178 1182 1186 1190 1194 1198 1202 1206 1210 1214 1218 1222 1226 1230 1234 1238 1242 1246 1250 1254 1258 1262 1266 1270 1274 1278 1282 1286 1290 1294 1298 1302 1306 1310 1314 1318 1322 1326 1330 1334 1338 1342 1346 1350 1354 1358 1362 1366 1370 1374 1378 1382 1386 1390 1394 1398 1402 1406 1410 1414 1418 1422 1426 1430 1434 1438 1442 1446 1450 1454 1458 1462 1466 1470 1474 1478 1482 1486 1490 1494 1498 1502 1506 1510 1514 1518 1522 1526 1530 1534 1538 1542 1546 1550 1554 1558 1562 1566 1570 1574 1578 1582 1586 1590 1594 1598 1602 1606 1610 1614 1618 1622 1626 1630 1634 1638 1642 1646 1650 1654 1658 1662 1666 1670 1674 1678 1682 1686 1690 1694 1698 1702 1706 1710 1714 1718 1722 1726 1730 1734 1738 1742 1746 1750 1754 1758 1762 1766 1770 1774 1778 1782 1786 1790 1794 1798 1802 1806 1810 1814 1818 1822 1826 1830 1834 1838 1842 1846 1850 1854 1858
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
else{
array[i*j]=1;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=0; i<)
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<=array.length; i++){
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<=array.length; i++){
if(i)
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<=array.length; i++){
if(i)
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 50000 at Solution.solution(Solution.java:18) at Exec.run(exec.java:50) at Exec.main(exec.java:36)
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50000];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 50000 at Solution.solution(Solution.java:18) at Exec.run(exec.java:50) at Exec.main(exec.java:36)
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 50001 at Solution.solution(Solution.java:18) at Exec.run(exec.java:50) at Exec.main(exec.java:36)
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<=array.length; i++){
for(int j=2; i*j<=array.length; j++){
if(array[i] == 1){
break;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
4 6 10 14 22 26 34 38 46 58 62 74 82 86 94 106 118 122 134 142 146 158 166 178 194 202 206 214 218 226 254 262 274 278 298 302 314 326 334 346 358 362 382 386 394 398 422 446 454 458 466 478 482 502 514 526 538 542 554 562 566 586 614 622 626 634 662 674 694 698 706 718 734 746 758 766 778 794 802 818 838 842 862 866 878 886 898 914 922 926 934 958 974 982 998 1006 1018 1042 1046 1082 1094 1114 1126 1138 1142 1154 1174 1186 1198 1202 1214 1226 1234 1238 1262 1282 1286 1294 1306 1318 1322 1346 1354 1366 1382 1402 1418 1438 1454 1466 1478 1486 1502 1514 1522 1538 1546 1574 1594 1618 1622 1642 1646 1654 1658 1678 1706 1714 1718 1726 1754 1762 1766 1774 1814 1822 1838 1858 1874 1882 1894 1906 1934 1942 1954 1966 1982 1994 2018 2026 2038 2042 2062 2066 2078 2098 2102 2122 2126 2138 2174 2182 2186 2194 2206 2218 2234 2246 2258 2302 2306 2326 2342 2362 2374 2386 2402 2426 2434 2446 2458 2462 2474 2498 2518 2554 2558 2566 2578 2582 2594 2602 2606 2614 2638 2642 2654 2722 2734 2746 2762 2798 2818 2846 2854 2858 2866 2878 2894 2902 2906 2918 2942 2962 2966 2974 2978 2986 2998 3022 3046 3062 3086 3098 3106 3118 3134 3142 3158 3166 3194 3202 3214 3218 3226 3238 3242 3254 3274 3314 3326 3334 3338 3386 3394 3398 3418 3442 3446 3466 3482 3494 3506 3518 3554 3566 3574 3578 3602 3622 3646 3662 3694 3722 3734 3742 3746 3754 3758 3778 3802 3814 3826 3862 3866 3898 3902 3946 3958 3974 3986 3994 3998 4006 4022 4034 4054 4058 4078 4106 4126 4138 4162 4166 4174 4178 4198 4222 4226 4258 4262 4274 4282 4286 4306 4322 4358 4406 4414 4426 4442 4474 4478 4486 4502 4534 4538 4546 4562 4574 4586 4594 4618 4622 4666 4678 4682 4694 4702 4714 4742 4754 4762 4766 4778 4786 4798 4822 4834 4846 4874 4882 4894 4918 4934 4946 4954 5006 5042 5062 5078 5086 5098 5102 5114 5158 5182 5186 5218 5234 5242 5266 5294 5314 5318 5326 5342 5354 5366 5374 5378 5386 5398 5414 5422 5426 5438 5458 5462 5482 5498 5506 5534 5554 5578 5582 5594 5602 5606 5638 5666 5674 5686 5702 5714 5722 5758 5774 5794 5806 5818 5834 5854 5878 5906 5914 5926 5938 5942 5998 6002 6022
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i=array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i=array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
Solution.java:22: error: incompatible types: int cannot be converted to boolean for(int i=2; i=array.length; i++){ ^ 1 error
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
4 6 10 14 22 26 34 38 46 58 62 74 82 86 94 106 118 122 134 142 146 158 166 178 194 202 206 214 218 226 254 262 274 278 298 302 314 326 334 346 358 362 382 386 394 398 422 446 454 458 466 478 482 502 514 526 538 542 554 562 566 586 614 622 626 634 662 674 694 698 706 718 734 746 758 766 778 794 802 818 838 842 862 866 878 886 898 914 922 926 934 958 974 982 998 1006 1018 1042 1046 1082 1094 1114 1126 1138 1142 1154 1174 1186 1198 1202 1214 1226 1234 1238 1262 1282 1286 1294 1306 1318 1322 1346 1354 1366 1382 1402 1418 1438 1454 1466 1478 1486 1502 1514 1522 1538 1546 1574 1594 1618 1622 1642 1646 1654 1658 1678 1706 1714 1718 1726 1754 1762 1766 1774 1814 1822 1838 1858 1874 1882 1894 1906 1934 1942 1954 1966 1982 1994 2018 2026 2038 2042 2062 2066 2078 2098 2102 2122 2126 2138 2174 2182 2186 2194 2206 2218 2234 2246 2258 2302 2306 2326 2342 2362 2374 2386 2402 2426 2434 2446 2458 2462 2474 2498 2518 2554 2558 2566 2578 2582 2594 2602 2606 2614 2638 2642 2654 2722 2734 2746 2762 2798 2818 2846 2854 2858 2866 2878 2894 2902 2906 2918 2942 2962 2966 2974 2978 2986 2998 3022 3046 3062 3086 3098 3106 3118 3134 3142 3158 3166 3194 3202 3214 3218 3226 3238 3242 3254 3274 3314 3326 3334 3338 3386 3394 3398 3418 3442 3446 3466 3482 3494 3506 3518 3554 3566 3574 3578 3602 3622 3646 3662 3694 3722 3734 3742 3746 3754 3758 3778 3802 3814 3826 3862 3866 3898 3902 3946 3958 3974 3986 3994 3998 4006 4022 4034 4054 4058 4078 4106 4126 4138 4162 4166 4174 4178 4198 4222 4226 4258 4262 4274 4282 4286 4306 4322 4358 4406 4414 4426 4442 4474 4478 4486 4502 4534 4538 4546 4562 4574 4586 4594 4618 4622 4666 4678 4682 4694 4702 4714 4742 4754 4762 4766 4778 4786 4798 4822 4834 4846 4874 4882 4894 4918 4934 4946 4954 5006 5042 5062 5078 5086 5098 5102 5114 5158 5182 5186 5218 5234 5242 5266 5294 5314 5318 5326 5342 5354 5366 5374 5378 5386 5398 5414 5422 5426 5438 5458 5462 5482 5498 5506 5534 5554 5578 5582 5594 5602 5606 5638 5666 5674 5686 5702 5714 5722 5758 5774 5794 5806 5818 5834 5854 5878 5906 5914 5926 5938 5942 5998 6002 6022
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
\
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
4 6 10 14 22 26 34 38 46 58 62 74 82 86 94 106 118 122 134 142 146 158 166 178 194 202 206 214 218 226 254 262 274 278 298 302 314 326 334 346 358 362 382 386 394 398 422 446 454 458 466 478 482 502 514 526 538 542 554 562 566 586 614 622 626 634 662 674 694 698 706 718 734 746 758 766 778 794 802 818 838 842 862 866 878 886 898 914 922 926 934 958 974 982 998 1006 1018 1042 1046 1082 1094 1114 1126 1138 1142 1154 1174 1186 1198 1202 1214 1226 1234 1238 1262 1282 1286 1294 1306 1318 1322 1346 1354 1366 1382 1402 1418 1438 1454 1466 1478 1486 1502 1514 1522 1538 1546 1574 1594 1618 1622 1642 1646 1654 1658 1678 1706 1714 1718 1726 1754 1762 1766 1774 1814 1822 1838 1858 1874 1882 1894 1906 1934 1942 1954 1966 1982 1994 2018 2026 2038 2042 2062 2066 2078 2098 2102 2122 2126 2138 2174 2182 2186 2194 2206 2218 2234 2246 2258 2302 2306 2326 2342 2362 2374 2386 2402 2426 2434 2446 2458 2462 2474 2498 2518 2554 2558 2566 2578 2582 2594 2602 2606 2614 2638 2642 2654 2722 2734 2746 2762 2798 2818 2846 2854 2858 2866 2878 2894 2902 2906 2918 2942 2962 2966 2974 2978 2986 2998 3022 3046 3062 3086 3098 3106 3118 3134 3142 3158 3166 3194 3202 3214 3218 3226 3238 3242 3254 3274 3314 3326 3334 3338 3386 3394 3398 3418 3442 3446 3466 3482 3494 3506 3518 3554 3566 3574 3578 3602 3622 3646 3662 3694 3722 3734 3742 3746 3754 3758 3778 3802 3814 3826 3862 3866 3898 3902 3946 3958 3974 3986 3994 3998 4006 4022 4034 4054 4058 4078 4106 4126 4138 4162 4166 4174 4178 4198 4222 4226 4258 4262 4274 4282 4286 4306 4322 4358 4406 4414 4426 4442 4474 4478 4486 4502 4534 4538 4546 4562 4574 4586 4594 4618 4622 4666 4678 4682 4694 4702 4714 4742 4754 4762 4766 4778 4786 4798 4822 4834 4846 4874 4882 4894 4918 4934 4946 4954 5006 5042 5062 5078 5086 5098 5102 5114 5158 5182 5186 5218 5234 5242 5266 5294 5314 5318 5326 5342 5354 5366 5374 5378 5386 5398 5414 5422 5426 5438 5458 5462 5482 5498 5506 5534 5554 5578 5582 5594 5602 5606 5638 5666 5674 5686 5702 5714 5722 5758 5774 5794 5806 5818 5834 5854 5878 5906 5914 5926 5938 5942 5998 6002 6022
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
System.out.println(i*j);
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
System.out.println(array[3]);
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
0 4 6 10 14 22 26 34 38 46 58 62 74 82 86 94 106 118 122 134 142 146 158 166 178 194 202 206 214 218 226 254 262 274 278 298 302 314 326 334 346 358 362 382 386 394 398 422 446 454 458 466 478 482 502 514 526 538 542 554 562 566 586 614 622 626 634 662 674 694 698 706 718 734 746 758 766 778 794 802 818 838 842 862 866 878 886 898 914 922 926 934 958 974 982 998 1006 1018 1042 1046 1082 1094 1114 1126 1138 1142 1154 1174 1186 1198 1202 1214 1226 1234 1238 1262 1282 1286 1294 1306 1318 1322 1346 1354 1366 1382 1402 1418 1438 1454 1466 1478 1486 1502 1514 1522 1538 1546 1574 1594 1618 1622 1642 1646 1654 1658 1678 1706 1714 1718 1726 1754 1762 1766 1774 1814 1822 1838 1858 1874 1882 1894 1906 1934 1942 1954 1966 1982 1994 2018 2026 2038 2042 2062 2066 2078 2098 2102 2122 2126 2138 2174 2182 2186 2194 2206 2218 2234 2246 2258 2302 2306 2326 2342 2362 2374 2386 2402 2426 2434 2446 2458 2462 2474 2498 2518 2554 2558 2566 2578 2582 2594 2602 2606 2614 2638 2642 2654 2722 2734 2746 2762 2798 2818 2846 2854 2858 2866 2878 2894 2902 2906 2918 2942 2962 2966 2974 2978 2986 2998 3022 3046 3062 3086 3098 3106 3118 3134 3142 3158 3166 3194 3202 3214 3218 3226 3238 3242 3254 3274 3314 3326 3334 3338 3386 3394 3398 3418 3442 3446 3466 3482 3494 3506 3518 3554 3566 3574 3578 3602 3622 3646 3662 3694 3722 3734 3742 3746 3754 3758 3778 3802 3814 3826 3862 3866 3898 3902 3946 3958 3974 3986 3994 3998 4006 4022 4034 4054 4058 4078 4106 4126 4138 4162 4166 4174 4178 4198 4222 4226 4258 4262 4274 4282 4286 4306 4322 4358 4406 4414 4426 4442 4474 4478 4486 4502 4534 4538 4546 4562 4574 4586 4594 4618 4622 4666 4678 4682 4694 4702 4714 4742 4754 4762 4766 4778 4786 4798 4822 4834 4846 4874 4882 4894 4918 4934 4946 4954 5006 5042 5062 5078 5086 5098 5102 5114 5158 5182 5186 5218 5234 5242 5266 5294 5314 5318 5326 5342 5354 5366 5374 5378 5386 5398 5414 5422 5426 5438 5458 5462 5482 5498 5506 5534 5554 5578 5582 5594 5602 5606 5638 5666 5674 5686 5702 5714 5722 5758 5774 5794 5806 5818 5834 5854 5878 5906 5914 5926 5938 5942 5998 6002 602
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
System.out.println(i*j);
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
System.out.println(array[3]);
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
System.out.println(array[3]);
System.out.println(array[2]);
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
0 0 4 6 10 14 22 26 34 38 46 58 62 74 82 86 94 106 118 122 134 142 146 158 166 178 194 202 206 214 218 226 254 262 274 278 298 302 314 326 334 346 358 362 382 386 394 398 422 446 454 458 466 478 482 502 514 526 538 542 554 562 566 586 614 622 626 634 662 674 694 698 706 718 734 746 758 766 778 794 802 818 838 842 862 866 878 886 898 914 922 926 934 958 974 982 998 1006 1018 1042 1046 1082 1094 1114 1126 1138 1142 1154 1174 1186 1198 1202 1214 1226 1234 1238 1262 1282 1286 1294 1306 1318 1322 1346 1354 1366 1382 1402 1418 1438 1454 1466 1478 1486 1502 1514 1522 1538 1546 1574 1594 1618 1622 1642 1646 1654 1658 1678 1706 1714 1718 1726 1754 1762 1766 1774 1814 1822 1838 1858 1874 1882 1894 1906 1934 1942 1954 1966 1982 1994 2018 2026 2038 2042 2062 2066 2078 2098 2102 2122 2126 2138 2174 2182 2186 2194 2206 2218 2234 2246 2258 2302 2306 2326 2342 2362 2374 2386 2402 2426 2434 2446 2458 2462 2474 2498 2518 2554 2558 2566 2578 2582 2594 2602 2606 2614 2638 2642 2654 2722 2734 2746 2762 2798 2818 2846 2854 2858 2866 2878 2894 2902 2906 2918 2942 2962 2966 2974 2978 2986 2998 3022 3046 3062 3086 3098 3106 3118 3134 3142 3158 3166 3194 3202 3214 3218 3226 3238 3242 3254 3274 3314 3326 3334 3338 3386 3394 3398 3418 3442 3446 3466 3482 3494 3506 3518 3554 3566 3574 3578 3602 3622 3646 3662 3694 3722 3734 3742 3746 3754 3758 3778 3802 3814 3826 3862 3866 3898 3902 3946 3958 3974 3986 3994 3998 4006 4022 4034 4054 4058 4078 4106 4126 4138 4162 4166 4174 4178 4198 4222 4226 4258 4262 4274 4282 4286 4306 4322 4358 4406 4414 4426 4442 4474 4478 4486 4502 4534 4538 4546 4562 4574 4586 4594 4618 4622 4666 4678 4682 4694 4702 4714 4742 4754 4762 4766 4778 4786 4798 4822 4834 4846 4874 4882 4894 4918 4934 4946 4954 5006 5042 5062 5078 5086 5098 5102 5114 5158 5182 5186 5218 5234 5242 5266 5294 5314 5318 5326 5342 5354 5366 5374 5378 5386 5398 5414 5422 5426 5438 5458 5462 5482 5498 5506 5534 5554 5578 5582 5594 5602 5606 5638 5666 5674 5686 5702 5714 5722 5758 5774 5794 5806 5818 5834 5854 5878 5906 5914 5926 5938 5942 5998 6002 6
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
System.out.println(array[3]);
System.out.println(array[]);
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
System.out.println(array[3]);
System.out.println(array[9]);
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
0 1 4 6 10 14 22 26 34 38 46 58 62 74 82 86 94 106 118 122 134 142 146 158 166 178 194 202 206 214 218 226 254 262 274 278 298 302 314 326 334 346 358 362 382 386 394 398 422 446 454 458 466 478 482 502 514 526 538 542 554 562 566 586 614 622 626 634 662 674 694 698 706 718 734 746 758 766 778 794 802 818 838 842 862 866 878 886 898 914 922 926 934 958 974 982 998 1006 1018 1042 1046 1082 1094 1114 1126 1138 1142 1154 1174 1186 1198 1202 1214 1226 1234 1238 1262 1282 1286 1294 1306 1318 1322 1346 1354 1366 1382 1402 1418 1438 1454 1466 1478 1486 1502 1514 1522 1538 1546 1574 1594 1618 1622 1642 1646 1654 1658 1678 1706 1714 1718 1726 1754 1762 1766 1774 1814 1822 1838 1858 1874 1882 1894 1906 1934 1942 1954 1966 1982 1994 2018 2026 2038 2042 2062 2066 2078 2098 2102 2122 2126 2138 2174 2182 2186 2194 2206 2218 2234 2246 2258 2302 2306 2326 2342 2362 2374 2386 2402 2426 2434 2446 2458 2462 2474 2498 2518 2554 2558 2566 2578 2582 2594 2602 2606 2614 2638 2642 2654 2722 2734 2746 2762 2798 2818 2846 2854 2858 2866 2878 2894 2902 2906 2918 2942 2962 2966 2974 2978 2986 2998 3022 3046 3062 3086 3098 3106 3118 3134 3142 3158 3166 3194 3202 3214 3218 3226 3238 3242 3254 3274 3314 3326 3334 3338 3386 3394 3398 3418 3442 3446 3466 3482 3494 3506 3518 3554 3566 3574 3578 3602 3622 3646 3662 3694 3722 3734 3742 3746 3754 3758 3778 3802 3814 3826 3862 3866 3898 3902 3946 3958 3974 3986 3994 3998 4006 4022 4034 4054 4058 4078 4106 4126 4138 4162 4166 4174 4178 4198 4222 4226 4258 4262 4274 4282 4286 4306 4322 4358 4406 4414 4426 4442 4474 4478 4486 4502 4534 4538 4546 4562 4574 4586 4594 4618 4622 4666 4678 4682 4694 4702 4714 4742 4754 4762 4766 4778 4786 4798 4822 4834 4846 4874 4882 4894 4918 4934 4946 4954 5006 5042 5062 5078 5086 5098 5102 5114 5158 5182 5186 5218 5234 5242 5266 5294 5314 5318 5326 5342 5354 5366 5374 5378 5386 5398 5414 5422 5426 5438 5458 5462 5482 5498 5506 5534 5554 5578 5582 5594 5602 5606 5638 5666 5674 5686 5702 5714 5722 5758 5774 5794 5806 5818 5834 5854 5878 5906 5914 5926 5938 5942 5998 6002 6
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
System.out.println(array[3]);
System.out.println(array[9]);
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
System.out.println(array[3]);
System.out.println(array[9]);
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if()
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
System.out.println(array[3]);
System.out.println(array[9]);
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(i==3){
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
System.out.println(array[3]);
System.out.println(array[9]);
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(i==3){
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
System.out.println(array[3]);
System.out.println(array[9]);
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(i==3){
System.out.println(i*j);
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
0 1 4 6 10 14 22 26 34 38 46 58 62 74 82 86 94 106 118 122 134 142 146 158 166 178 194 202 206 214 218 226 254 262 274 278 298 302 314 326 334 346 358 362 382 386 394 398 422 446 454 458 466 478 482 502 514 526 538 542 554 562 566 586 614 622 626 634 662 674 694 698 706 718 734 746 758 766 778 794 802 818 838 842 862 866 878 886 898 914 922 926 934 958 974 982 998 1006 1018 1042 1046 1082 1094 1114 1126 1138 1142 1154 1174 1186 1198 1202 1214 1226 1234 1238 1262 1282 1286 1294 1306 1318 1322 1346 1354 1366 1382 1402 1418 1438 1454 1466 1478 1486 1502 1514 1522 1538 1546 1574 1594 1618 1622 1642 1646 1654 1658 1678 1706 1714 1718 1726 1754 1762 1766 1774 1814 1822 1838 1858 1874 1882 1894 1906 1934 1942 1954 1966 1982 1994 2018 2026 2038 2042 2062 2066 2078 2098 2102 2122 2126 2138 2174 2182 2186 2194 2206 2218 2234 2246 2258 2302 2306 2326 2342 2362 2374 2386 2402 2426 2434 2446 2458 2462 2474 2498 2518 2554 2558 2566 2578 2582 2594 2602 2606 2614 2638 2642 2654 2722 2734 2746 2762 2798 2818 2846 2854 2858 2866 2878 2894 2902 2906 2918 2942 2962 2966 2974 2978 2986 2998 3022 3046 3062 3086 3098 3106 3118 3134 3142 3158 3166 3194 3202 3214 3218 3226 3238 3242 3254 3274 3314 3326 3334 3338 3386 3394 3398 3418 3442 3446 3466 3482 3494 3506 3518 3554 3566 3574 3578 3602 3622 3646 3662 3694 3722 3734 3742 3746 3754 3758 3778 3802 3814 3826 3862 3866 3898 3902 3946 3958 3974 3986 3994 3998 4006 4022 4034 4054 4058 4078 4106 4126 4138 4162 4166 4174 4178 4198 4222 4226 4258 4262 4274 4282 4286 4306 4322 4358 4406 4414 4426 4442 4474 4478 4486 4502 4534 4538 4546 4562 4574 4586 4594 4618 4622 4666 4678 4682 4694 4702 4714 4742 4754 4762 4766 4778 4786 4798 4822 4834 4846 4874 4882 4894 4918 4934 4946 4954 5006 5042 5062 5078 5086 5098 5102 5114 5158 5182 5186 5218 5234 5242 5266 5294 5314 5318 5326 5342 5354 5366 5374 5378 5386 5398 5414 5422 5426 5438 5458 5462 5482 5498 5506 5534 5554 5578 5582 5594 5602 5606 5638 5666 5674 5686 5702 5714 5722 5758 5774 5794 5806 5818 5834 5854 5878 5906 5914 5926 5938 5942 5998 6002 6
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(i==3){
System.out.println(i*j);
}
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(i==3){
System.out.println(i*j);
}
if(array[i] == 0 && array[j] == 0){
++cnt;
//System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 102 105 108 111 114 117 120 123 126 129 132 135 138 141 144 147 150 153 156 159 162 165 168 171 174 177 180 183 186 189 192 195 198 201 204 207 210 213 216 219 222 225 228 231 234 237 240 243 246 249 252 255 258 261 264 267 270 273 276 279 282 285 288 291 294 297 300 303 306 309 312 315 318 321 324 327 330 333 336 339 342 345 348 351 354 357 360 363 366 369 372 375 378 381 384 387 390 393 396 399 402 405 408 411 414 417 420 423 426 429 432 435 438 441 444 447 450 453 456 459 462 465 468 471 474 477 480 483 486 489 492 495 498 501 504 507 510 513 516 519 522 525 528 531 534 537 540 543 546 549 552 555 558 561 564 567 570 573 576 579 582 585 588 591 594 597 600 603 606 609 612 615 618 621 624 627 630 633 636 639 642 645 648 651 654 657 660 663 666 669 672 675 678 681 684 687 690 693 696 699 702 705 708 711 714 717 720 723 726 729 732 735 738 741 744 747 750 753 756 759 762 765 768 771 774 777 780 783 786 789 792 795 798 801 804 807 810 813 816 819 822 825 828 831 834 837 840 843 846 849 852 855 858 861 864 867 870 873 876 879 882 885 888 891 894 897 900 903 906 909 912 915 918 921 924 927 930 933 936 939 942 945 948 951 954 957 960 963 966 969 972 975 978 981 984 987 990 993 996 999 1002 1005 1008 1011 1014 1017 1020 1023 1026 1029 1032 1035 1038 1041 1044 1047 1050 1053 1056 1059 1062 1065 1068 1071 1074 1077 1080 1083 1086 1089 1092 1095 1098 1101 1104 1107 1110 1113 1116 1119 1122 1125 1128 1131 1134 1137 1140 1143 1146 1149 1152 1155 1158 1161 1164 1167 1170 1173 1176 1179 1182 1185 1188 1191 1194 1197 1200 1203 1206 1209 1212 1215 1218 1221 1224 1227 1230 1233 1236 1239 1242 1245 1248 1251 1254 1257 1260 1263 1266 1269 1272 1275 1278 1281 1284 1287 1290 1293 1296 1299 1302 1305 1308 1311 1314 1317 1320 1323 1326 1329 1332 1335 1338 1341 1344 1347 1350 1353 1356 1359 1362 1365 1368 1371 1374 1377 1380 1383 1386 1389 1392 1395 1398 1401 1404 1407 1410 1413 1416 1419 1422 1425 1428 1431 1434 1437 1440 1443 1446 1449 1452
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(i==3){
System.out.println(i*j);
if(array[i] == 0 && array[j] == 0){
}
}
if(array[i] == 0 && array[j] == 0){
++cnt;
//System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(i==3){
if(array[i] == 0 && array[j] == 0){
System.out.println(i*j);
}
}
if(array[i] == 0 && array[j] == 0){
++cnt;
//System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
6 9 15 21 33 39 51 57 69 87 93 111 123 129 141 159 177 183 201 213 219 237 249 267 291 303 309 321 327 339 381 393 411 417 447 453 471 489 501 519 537 543 573 579 591 597 633 669 681 687 699 717 723 753 771 789 807 813 831 843 849 879 921 933 939 951 993 1011 1041 1047 1059 1077 1101 1119 1137 1149 1167 1191 1203 1227 1257 1263 1293 1299 1317 1329 1347 1371 1383 1389 1401 1437 1461 1473 1497 1509 1527 1563 1569 1623 1641 1671 1689 1707 1713 1731 1761 1779 1797 1803 1821 1839 1851 1857 1893 1923 1929 1941 1959 1977 1983 2019 2031 2049 2073 2103 2127 2157 2181 2199 2217 2229 2253 2271 2283 2307 2319 2361 2391 2427 2433 2463 2469 2481 2487 2517 2559 2571 2577 2589 2631 2643 2649 2661 2721 2733 2757 2787 2811 2823 2841 2859 2901 2913 2931 2949 2973 2991 3027 3039 3057 3063 3093 3099 3117 3147 3153 3183 3189 3207 3261 3273 3279 3291 3309 3327 3351 3369 3387 3453 3459 3489 3513 3543 3561 3579 3603 3639 3651 3669 3687 3693 3711 3747 3777 3831 3837 3849 3867 3873 3891 3903 3909 3921 3957 3963 3981 4083 4101 4119 4143 4197 4227 4269 4281 4287 4299 4317 4341 4353 4359 4377 4413 4443 4449 4461 4467 4479 4497 4533 4569 4593 4629 4647 4659 4677 4701 4713 4737 4749 4791 4803 4821 4827 4839 4857 4863 4881 4911 4971 4989 5001 5007 5079 5091 5097 5127 5163 5169 5199 5223 5241 5259 5277 5331 5349 5361 5367 5403 5433 5469 5493 5541 5583 5601 5613 5619 5631 5637 5667 5703 5721 5739 5793 5799 5847 5853 5919 5937 5961 5979 5991 5997 6009 6033 6051 6081 6087 6117 6159 6189 6207 6243 6249 6261 6267 6297 6333 6339 6387 6393 6411 6423 6429 6459 6483 6537 6609 6621 6639 6663 6711 6717 6729 6753 6801 6807 6819 6843 6861 6879 6891 6927 6933 6999 7017 7023 7041 7053 7071 7113 7131 7143 7149 7167 7179 7197 7233 7251 7269 7311 7323 7341 7377 7401 7419 7431 7509 7563 7593 7617 7629 7647 7653 7671 7737 7773 7779 7827 7851 7863 7899 7941 7971 7977 7989 8013 8031 8049 8061 8067 8079 8097 8121 8133 8139 8157 8187 8193 8223 8247 8259 8301 8331 8367 8373 8391 8403 8409 8457 8499 8511 8529 8553 8571 8583 8637 8661 8691 8709 8727 8751 8781 8817 8859 887
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
//System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
4 6 10 14 22 26 34 38 46 58 62 74 82 86 94 106 118 122 134 142 146 158 166 178 194 202 206 214 218 226 254 262 274 278 298 302 314 326 334 346 358 362 382 386 394 398 422 446 454 458 466 478 482 502 514 526 538 542 554 562 566 586 614 622 626 634 662 674 694 698 706 718 734 746 758 766 778 794 802 818 838 842 862 866 878 886 898 914 922 926 934 958 974 982 998 1006 1018 1042 1046 1082 1094 1114 1126 1138 1142 1154 1174 1186 1198 1202 1214 1226 1234 1238 1262 1282 1286 1294 1306 1318 1322 1346 1354 1366 1382 1402 1418 1438 1454 1466 1478 1486 1502 1514 1522 1538 1546 1574 1594 1618 1622 1642 1646 1654 1658 1678 1706 1714 1718 1726 1754 1762 1766 1774 1814 1822 1838 1858 1874 1882 1894 1906 1934 1942 1954 1966 1982 1994 2018 2026 2038 2042 2062 2066 2078 2098 2102 2122 2126 2138 2174 2182 2186 2194 2206 2218 2234 2246 2258 2302 2306 2326 2342 2362 2374 2386 2402 2426 2434 2446 2458 2462 2474 2498 2518 2554 2558 2566 2578 2582 2594 2602 2606 2614 2638 2642 2654 2722 2734 2746 2762 2798 2818 2846 2854 2858 2866 2878 2894 2902 2906 2918 2942 2962 2966 2974 2978 2986 2998 3022 3046 3062 3086 3098 3106 3118 3134 3142 3158 3166 3194 3202 3214 3218 3226 3238 3242 3254 3274 3314 3326 3334 3338 3386 3394 3398 3418 3442 3446 3466 3482 3494 3506 3518 3554 3566 3574 3578 3602 3622 3646 3662 3694 3722 3734 3742 3746 3754 3758 3778 3802 3814 3826 3862 3866 3898 3902 3946 3958 3974 3986 3994 3998 4006 4022 4034 4054 4058 4078 4106 4126 4138 4162 4166 4174 4178 4198 4222 4226 4258 4262 4274 4282 4286 4306 4322 4358 4406 4414 4426 4442 4474 4478 4486 4502 4534 4538 4546 4562 4574 4586 4594 4618 4622 4666 4678 4682 4694 4702 4714 4742 4754 4762 4766 4778 4786 4798 4822 4834 4846 4874 4882 4894 4918 4934 4946 4954 5006 5042 5062 5078 5086 5098 5102 5114 5158 5182 5186 5218 5234 5242 5266 5294 5314 5318 5326 5342 5354 5366 5374 5378 5386 5398 5414 5422 5426 5438 5458 5462 5482 5498 5506 5534 5554 5578 5582 5594 5602 5606 5638 5666 5674 5686 5702 5714 5722 5758 5774 5794 5806 5818 5834 5854 5878 5906 5914 5926 5938 5942 5998 6002 6022
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
for(int )
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
++cnt;
System.out.println(i*j);
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
System.out.println(i*j);
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
flag[i] = cnt;
}
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
System.out.println(i*j);
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
flag[i] = cnt;
}
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i+_)
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
System.out.println(i*j);
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
flag[i] = cnt;
}
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i++){
ans[i]= flag[]
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
System.out.println(i*j);
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
flag[i] = cnt;
}
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i++){
ans[i]= flag[Q[i]] - flag[P[i]];
}
return ans;
}
}
4 6 10 14 22 26 34 38 46 58 62 74 82 86 94 106 118 122 134 142 146 158 166 178 194 202 206 214 218 226 254 262 274 278 298 302 314 326 334 346 358 362 382 386 394 398 422 446 454 458 466 478 482 502 514 526 538 542 554 562 566 586 614 622 626 634 662 674 694 698 706 718 734 746 758 766 778 794 802 818 838 842 862 866 878 886 898 914 922 926 934 958 974 982 998 1006 1018 1042 1046 1082 1094 1114 1126 1138 1142 1154 1174 1186 1198 1202 1214 1226 1234 1238 1262 1282 1286 1294 1306 1318 1322 1346 1354 1366 1382 1402 1418 1438 1454 1466 1478 1486 1502 1514 1522 1538 1546 1574 1594 1618 1622 1642 1646 1654 1658 1678 1706 1714 1718 1726 1754 1762 1766 1774 1814 1822 1838 1858 1874 1882 1894 1906 1934 1942 1954 1966 1982 1994 2018 2026 2038 2042 2062 2066 2078 2098 2102 2122 2126 2138 2174 2182 2186 2194 2206 2218 2234 2246 2258 2302 2306 2326 2342 2362 2374 2386 2402 2426 2434 2446 2458 2462 2474 2498 2518 2554 2558 2566 2578 2582 2594 2602 2606 2614 2638 2642 2654 2722 2734 2746 2762 2798 2818 2846 2854 2858 2866 2878 2894 2902 2906 2918 2942 2962 2966 2974 2978 2986 2998 3022 3046 3062 3086 3098 3106 3118 3134 3142 3158 3166 3194 3202 3214 3218 3226 3238 3242 3254 3274 3314 3326 3334 3338 3386 3394 3398 3418 3442 3446 3466 3482 3494 3506 3518 3554 3566 3574 3578 3602 3622 3646 3662 3694 3722 3734 3742 3746 3754 3758 3778 3802 3814 3826 3862 3866 3898 3902 3946 3958 3974 3986 3994 3998 4006 4022 4034 4054 4058 4078 4106 4126 4138 4162 4166 4174 4178 4198 4222 4226 4258 4262 4274 4282 4286 4306 4322 4358 4406 4414 4426 4442 4474 4478 4486 4502 4534 4538 4546 4562 4574 4586 4594 4618 4622 4666 4678 4682 4694 4702 4714 4742 4754 4762 4766 4778 4786 4798 4822 4834 4846 4874 4882 4894 4918 4934 4946 4954 5006 5042 5062 5078 5086 5098 5102 5114 5158 5182 5186 5218 5234 5242 5266 5294 5314 5318 5326 5342 5354 5366 5374 5378 5386 5398 5414 5422 5426 5438 5458 5462 5482 5498 5506 5534 5554 5578 5582 5594 5602 5606 5638 5666 5674 5686 5702 5714 5722 5758 5774 5794 5806 5818 5834 5854 5878 5906 5914 5926 5938 5942 5998 6002 6022
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
System.out.println(i*j);
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
flag[i] = cnt;
}
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i++){
ans[i]= presum[Q[i]] - presum[P[i]-1];
}
return ans;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
System.out.println(i*j);
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
flag[i] = cnt;
}
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i++){
ans[i]= flag[Q[i]] - flag[P[i]-1];
}
return ans;
}
}
4 6 10 14 22 26 34 38 46 58 62 74 82 86 94 106 118 122 134 142 146 158 166 178 194 202 206 214 218 226 254 262 274 278 298 302 314 326 334 346 358 362 382 386 394 398 422 446 454 458 466 478 482 502 514 526 538 542 554 562 566 586 614 622 626 634 662 674 694 698 706 718 734 746 758 766 778 794 802 818 838 842 862 866 878 886 898 914 922 926 934 958 974 982 998 1006 1018 1042 1046 1082 1094 1114 1126 1138 1142 1154 1174 1186 1198 1202 1214 1226 1234 1238 1262 1282 1286 1294 1306 1318 1322 1346 1354 1366 1382 1402 1418 1438 1454 1466 1478 1486 1502 1514 1522 1538 1546 1574 1594 1618 1622 1642 1646 1654 1658 1678 1706 1714 1718 1726 1754 1762 1766 1774 1814 1822 1838 1858 1874 1882 1894 1906 1934 1942 1954 1966 1982 1994 2018 2026 2038 2042 2062 2066 2078 2098 2102 2122 2126 2138 2174 2182 2186 2194 2206 2218 2234 2246 2258 2302 2306 2326 2342 2362 2374 2386 2402 2426 2434 2446 2458 2462 2474 2498 2518 2554 2558 2566 2578 2582 2594 2602 2606 2614 2638 2642 2654 2722 2734 2746 2762 2798 2818 2846 2854 2858 2866 2878 2894 2902 2906 2918 2942 2962 2966 2974 2978 2986 2998 3022 3046 3062 3086 3098 3106 3118 3134 3142 3158 3166 3194 3202 3214 3218 3226 3238 3242 3254 3274 3314 3326 3334 3338 3386 3394 3398 3418 3442 3446 3466 3482 3494 3506 3518 3554 3566 3574 3578 3602 3622 3646 3662 3694 3722 3734 3742 3746 3754 3758 3778 3802 3814 3826 3862 3866 3898 3902 3946 3958 3974 3986 3994 3998 4006 4022 4034 4054 4058 4078 4106 4126 4138 4162 4166 4174 4178 4198 4222 4226 4258 4262 4274 4282 4286 4306 4322 4358 4406 4414 4426 4442 4474 4478 4486 4502 4534 4538 4546 4562 4574 4586 4594 4618 4622 4666 4678 4682 4694 4702 4714 4742 4754 4762 4766 4778 4786 4798 4822 4834 4846 4874 4882 4894 4918 4934 4946 4954 5006 5042 5062 5078 5086 5098 5102 5114 5158 5182 5186 5218 5234 5242 5266 5294 5314 5318 5326 5342 5354 5366 5374 5378 5386 5398 5414 5422 5426 5438 5458 5462 5482 5498 5506 5534 5554 5578 5582 5594 5602 5606 5638 5666 5674 5686 5702 5714 5722 5758 5774 5794 5806 5818 5834 5854 5878 5906 5914 5926 5938 5942 5998 6002 6022
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
System.out.println(i*j);
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
flag[i] = cnt;
}
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i++){
ans[i]= flag[Q[i]] - flag[P[i]];
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
System.out.println(i*j);
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
flag[i] = cnt;
}
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i++){
ans[i]= flag[Q[i]] - flag[P[i]];
}
return array;
}
}
4 6 10 14 22 26 34 38 46 58 62 74 82 86 94 106 118 122 134 142 146 158 166 178 194 202 206 214 218 226 254 262 274 278 298 302 314 326 334 346 358 362 382 386 394 398 422 446 454 458 466 478 482 502 514 526 538 542 554 562 566 586 614 622 626 634 662 674 694 698 706 718 734 746 758 766 778 794 802 818 838 842 862 866 878 886 898 914 922 926 934 958 974 982 998 1006 1018 1042 1046 1082 1094 1114 1126 1138 1142 1154 1174 1186 1198 1202 1214 1226 1234 1238 1262 1282 1286 1294 1306 1318 1322 1346 1354 1366 1382 1402 1418 1438 1454 1466 1478 1486 1502 1514 1522 1538 1546 1574 1594 1618 1622 1642 1646 1654 1658 1678 1706 1714 1718 1726 1754 1762 1766 1774 1814 1822 1838 1858 1874 1882 1894 1906 1934 1942 1954 1966 1982 1994 2018 2026 2038 2042 2062 2066 2078 2098 2102 2122 2126 2138 2174 2182 2186 2194 2206 2218 2234 2246 2258 2302 2306 2326 2342 2362 2374 2386 2402 2426 2434 2446 2458 2462 2474 2498 2518 2554 2558 2566 2578 2582 2594 2602 2606 2614 2638 2642 2654 2722 2734 2746 2762 2798 2818 2846 2854 2858 2866 2878 2894 2902 2906 2918 2942 2962 2966 2974 2978 2986 2998 3022 3046 3062 3086 3098 3106 3118 3134 3142 3158 3166 3194 3202 3214 3218 3226 3238 3242 3254 3274 3314 3326 3334 3338 3386 3394 3398 3418 3442 3446 3466 3482 3494 3506 3518 3554 3566 3574 3578 3602 3622 3646 3662 3694 3722 3734 3742 3746 3754 3758 3778 3802 3814 3826 3862 3866 3898 3902 3946 3958 3974 3986 3994 3998 4006 4022 4034 4054 4058 4078 4106 4126 4138 4162 4166 4174 4178 4198 4222 4226 4258 4262 4274 4282 4286 4306 4322 4358 4406 4414 4426 4442 4474 4478 4486 4502 4534 4538 4546 4562 4574 4586 4594 4618 4622 4666 4678 4682 4694 4702 4714 4742 4754 4762 4766 4778 4786 4798 4822 4834 4846 4874 4882 4894 4918 4934 4946 4954 5006 5042 5062 5078 5086 5098 5102 5114 5158 5182 5186 5218 5234 5242 5266 5294 5314 5318 5326 5342 5354 5366 5374 5378 5386 5398 5414 5422 5426 5438 5458 5462 5482 5498 5506 5534 5554 5578 5582 5594 5602 5606 5638 5666 5674 5686 5702 5714 5722 5758 5774 5794 5806 5818 5834 5854 5878 5906 5914 5926 5938 5942 5998 6002 6022
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
flag[i] = cnt;
}
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i++){
ans[i]= flag[Q[i]] - flag[P[i]];
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
flag[i] = cnt;
}
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i++){
ans[i]= flag[Q[i]] - flag[P[i-1]];
}
return array;
}
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 at Solution.solution(Solution.java:40) at Exec.run(exec.java:50) at Exec.main(exec.java:36)
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
flag[i] = cnt;
}
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i++){
ans[i]= flag[Q[i]] - flag[P[i-]];
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
flag[i] = cnt;
}
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i++){
ans[i]= flag[Q[i]] - flag[P[i]-1];
}
return array;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
flag[i] = cnt;
}
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i++){
ans[i]= flag[Q[i]] - flag[P[i]-1];
}
return ans;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
}
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i++){
ans[i]= flag[Q[i]] - flag[P[i]-1];
}
return ans;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
}
flag[i] = cnt;
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i++){
ans[i]= flag[Q[i]] - flag[P[i]-1];
}
return ans;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
}
flag[i] = cnt;
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i++){
ans[i]= flag[Q[i]] - flag[P[i]-1];
}
return ans;
}
}
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
class Solution {
public int[] solution(int N, int[] P, int[] Q) {
// write your code in Java SE 8
int[] array = new int[50001];
int[] flag = new int[50001];
array[1]=1;
int cnt = 0;
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 1){
break;
}
array[i*j]=1;
}
}
for(int i=2; i<array.length; i++){
for(int j=2; i*j<array.length; j++){
if(array[i] == 0 && array[j] == 0){
array[i*j]=2;
}
}
}
for(int i=0; i<array.length; i++){
if(array[i]==2){
cnt++;
}
flag[i] = cnt;
}
int[] ans = new int[P.length];
for(int i = 0; i<ans.length; i++){
ans[i]= flag[Q[i]] - flag[P[i]-1];
}
return ans;
}
}
The solution obtained perfect score.