Odd even prime multiples
Humans have finally made contact with aliens from outer space who call themselves Primes. Naturally, each of their individuals loves prime numbers. Their emperor loves the prime number p the most. However, their maths is much more advanced than the version we use on Earth. They have very long numbers with several digits going up to 100 digits. A number is said to be valid for them if it follows the following conditions:
Task
The emperor has sent the message that he will consider humans an intelligent life form if you can tell him the number of valid numbers between L and R (both inclusive). Since the number of such numbers can be too large, you only need to tell the answer modulo (109+7).
For Full Instructions and Note Please Use Those Images as reference... Please help
https://drive.google.com/file/d/1As_XKXCbB2L2zHCMvbDIZfUiN46_QArO/view?usp=sharing
https://drive.google.com/file/d/1XqxcnlhhjqTTLc8PYcfz7tMdW7AFmcKa/view?usp=sharing
def mod(num, a):
# // Initialize result
res = 0
for i in range(0,len(num)):
res = (res * 10 + (int)num[i] - '0') % a;
return res;
}
p = int(input())
l = input()
r = input()
c = 0
for k in range(int(l,int(r)+1):
i = k
if mod(i,p) == 0:
i = str(i)
for j in (0,len(i)):
if (j%2 == 0 and i[j] % 2 != 0) or (j%2 != 0 and i[j] % 2 == 0):
c += 1;
Comments
Leave a comment