File tree Expand file tree Collapse file tree 3 files changed +94
-0
lines changed Expand file tree Collapse file tree 3 files changed +94
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .io .*;
2
+ import java .util .*;
3
+
4
+ public class Solution {
5
+
6
+ public static void main (String [] args )
7
+ {
8
+ Scanner sc = new Scanner (System .in );
9
+ int n = sc .nextInt ();
10
+ for (int i =0 ; i <n ; i ++)
11
+ {
12
+ int c = 0 ;
13
+ int p = sc .nextInt ();
14
+ if (p ==1 )
15
+ System .out .println ("Not prime" );
16
+ for (int j =2 ; j *j <=p ;j ++)
17
+ {
18
+ if (p %j ==0 )
19
+ {
20
+ System .out .println ("Not prime" );
21
+ c ++;
22
+ break ;
23
+ }
24
+ }
25
+ if (c ==0 && p !=1 )
26
+ System .out .println ("Prime" );
27
+ }
28
+ }
29
+ }
Original file line number Diff line number Diff line change
1
+ import java .io .*;
2
+ import java .math .*;
3
+ import java .security .*;
4
+ import java .text .*;
5
+ import java .util .*;
6
+ import java .util .concurrent .*;
7
+ import java .util .regex .*;
8
+
9
+ public class Solution {
10
+
11
+
12
+
13
+ private static final Scanner scanner = new Scanner (System .in );
14
+
15
+ public static void main (String [] args ) {
16
+ int [][] arr = new int [6 ][6 ];
17
+ int max = -70 ;
18
+
19
+ for (int i = 0 ; i < 6 ; i ++) {
20
+ String [] arrRowItems = scanner .nextLine ().split (" " );
21
+ scanner .skip ("(\r \n |[\n \r \u2028 \u2029 \u0085 ])?" );
22
+
23
+ for (int j = 0 ; j < 6 ; j ++) {
24
+ int arrItem = Integer .parseInt (arrRowItems [j ]);
25
+ arr [i ][j ] = arrItem ;
26
+ }
27
+ }
28
+
29
+ for (int i =0 ;i <4 ;i ++)
30
+ {
31
+ for (int j =0 ;j <4 ;j ++)
32
+ {
33
+ int sum = arr [i ][j ] + arr [i ][j +1 ] + arr [i ][j +2 ] + arr [i +1 ][j +1 ] + arr [i +2 ][j ] + arr [i +2 ][j +1 ] + arr [i +2 ][j +2 ];
34
+ if (sum >= max )
35
+ max = sum ;
36
+ }
37
+ }
38
+
39
+ System .out .println (max );
40
+
41
+ scanner .close ();
42
+ }
43
+ }
Original file line number Diff line number Diff line change
1
+ import java .io .*;
2
+ import java .util .*;
3
+
4
+ public class Solution {
5
+
6
+ public static void main (String [] args ) {
7
+ Scanner scan = new Scanner (System .in );
8
+ String s = scan .nextLine ().trim ();
9
+
10
+ String [] str = s .split ("[ !,?._'@]+" );
11
+ int l = str .length ;
12
+ if (s .compareTo ("" )==0 )
13
+ System .out .println (0 );
14
+ else
15
+ {
16
+ System .out .println (l );
17
+ for (int i =0 ;i <l ;i ++)
18
+ System .out .println (str [i ]);
19
+ }
20
+ scan .close ();
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments