It was four completes from A to D.
** Thoughts ** Just do
a, b = map(int,input().split())
print(a*b)
** Thoughts ** If 0 is included, the product is 0, so sort them in ascending order.
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 1
for i in range(n):
ans *= a[i]
if ans > 10**18:
print(-1)
quit()
print(ans)
** Thoughts ** Yes. Because of this guy, the performance has fallen. Fuck. I was worried about the accuracy, so I used decimal. "Let's use quantize to truncate decimal! It's a promise !!!!"
from decimal import *
a, b = input().split()
a = Decimal(a)
b = Decimal(b)
ans = a * b
ans = ans.quantize(Decimal(0),rounding=ROUND_FLOOR)
print(ans)
** Thoughts ** For the time being, factor $ N $ into prime factors. Consider the case of sample case 1. Factoring 24 into $ 2 ^ 3 * 3 ^ 1 $. The maximum number of operations that can be performed at this time is $ 2 ^ 1,2 ^ 2,3 ^ 1 $. $ 2 ^ 3 $ is not a divisor of N, so you can't. The same is true for $ 3 ^ 2 $. From this, we can see that we should add them so that they do not exceed the exponential part of the prime factor of $ N $. (Example: In the case of 24, the number of 2 is 3 so it is up to 1 + 2, and the number of 3 is 1 so 1). All you have to do now is calculate how many times you can use each prime factor.
n = int(input())
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i==0:
cnt=0
while temp%i==0:
cnt+=1
temp //= i
arr.append([i, cnt])
if temp!=1:
arr.append([temp, 1])
if arr==[]:
arr.append([n, 1])
return arr
if n == 1:
print(0)
quit()
f = factorization(n)
ans = 0
c = len(f)
for i in range(c):
s = 0
g = f[i][1]
if g == 2:
ans += 1
else:
for j in range(g):
s += j + 1
f[i][1] -= j+1
if s > g:
break
ans += 1
print(ans)
Tax_free hated by C these days. I want to correct the habit of submitting due to brain death when such accuracy problems occur. See you again, good night.
Recommended Posts