File tree 3 files changed +42
-0
lines changed
3 files changed +42
-0
lines changed File renamed without changes.
Original file line number Diff line number Diff line change
1
+ import java .util .*;
2
+
3
+ public class A {
4
+ public static void main (String [] args ) {
5
+ Scanner sc = new Scanner (System .in );
6
+ int p = sc .nextInt (), n = sc .nextInt ();
7
+ int [] table = new int [p ];
8
+ Arrays .fill (table , -1 );
9
+ for (int i = 0 ; i < n ; i ++) {
10
+ int t = sc .nextInt ();
11
+ if (table [t % p ] == -1 ) {
12
+ table [t % p ] = t ;
13
+ continue ;
14
+ }
15
+ System .out .println (i + 1 );
16
+ return ;
17
+ }
18
+ System .out .println (-1 );
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ import java .util .*;
2
+
3
+ public class B {
4
+ public static void main (String [] args ) {
5
+ Scanner sc = new Scanner (System .in );
6
+ String s = sc .next ();
7
+ int k = sc .nextInt ();
8
+ int [] table = new int [26 ];
9
+ int max = 0 ;
10
+ for (int i = 0 ; i < table .length ; i ++) {
11
+ table [i ] = sc .nextInt ();
12
+ max = Math .max (table [i ], max );
13
+ }
14
+ int result = 0 ;
15
+ for (int i = 0 ; i < s .length (); i ++)
16
+ result += table [s .charAt (i ) - 'a' ] * (i + 1 );
17
+ for (int i = s .length (); i < s .length () + k ; i ++)
18
+ result += max * (i + 1 );
19
+ System .out .println (result );
20
+ sc .close ();
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments