-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeForces_449_2.java
More file actions
62 lines (58 loc) · 832 Bytes
/
codeForces_449_2.java
File metadata and controls
62 lines (58 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.util.*;
public class codeForces_449_2 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
long p = scan.nextLong();
long sum = 0,c=0;
for(int i=11;;i++)
{
int k = i;
while(k>0)
{
int rem = k%10;
if(rem==0)
{
k=k/10;
}
else
break;
}
int k2 = k;
int l = 0;
while(k2>0)
{
l++;
k2=k2/10;
}
if(l%2==0)
{
int a[] = new int[l];
int k3 = k,z=0;
while(k3>0)
{
a[z++] = k3%10;
k3/=10;
}
int flag=0;
for(int j=0;j<z;j++)
{
if(a[j]!=a[z-j-1])
{
flag=1;
break;
}
}
if(flag==0)
{
c++;
sum = sum + k;
if(c==n)
break;
}
}
}
long ans = sum%p;
System.out.println(ans);
}
}