Submission #3025163


Source Code Expand

N = int(input())
a = list(map(int, input().split()))

def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a%b)

def lcm(a, b):
  return a*b//gcd(a,b)

alcm = a[0]
for i in a[1:]:
  alcm = lcm(alcm, i)

res = 0

for i in range(N):
  res += (alcm-1) % a[i]

print(int(res))

Submission Info

Submission Time
Task C - Modulo Summation
User aki85
Language PyPy3 (2.4.0)
Score 300
Code Size 296 Byte
Status AC
Exec Time 406 ms
Memory 50032 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 18
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All 1_small_rand_0, 1_small_rand_1, 1_small_rand_2, 2_rand_0, 2_rand_1, 2_rand_2, 3_max_0, 3_max_1, 3_max_2, 4_prime_0, 4_prime_1, 4_prime_2, 5_hand_0, 5_hand_1, 5_hand_2, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
1_small_rand_0 AC 163 ms 38384 KB
1_small_rand_1 AC 164 ms 38256 KB
1_small_rand_2 AC 163 ms 38256 KB
2_rand_0 AC 201 ms 41456 KB
2_rand_1 AC 242 ms 45040 KB
2_rand_2 AC 180 ms 40944 KB
3_max_0 AC 283 ms 45548 KB
3_max_1 AC 278 ms 45164 KB
3_max_2 AC 275 ms 44652 KB
4_prime_0 AC 375 ms 49264 KB
4_prime_1 AC 339 ms 46700 KB
4_prime_2 AC 368 ms 50032 KB
5_hand_0 AC 406 ms 49132 KB
5_hand_1 AC 175 ms 39664 KB
5_hand_2 AC 171 ms 39536 KB
sample_01 AC 163 ms 38256 KB
sample_02 AC 170 ms 38256 KB
sample_03 AC 164 ms 38256 KB