input
stringlengths
20
127k
target
stringlengths
20
119k
problem_id
stringlengths
6
6
import sys sys.setrecursionlimit(10**5) def dfs(N, B, A, seq, nums): if len(A) == N: ok = True for a, b in zip(A, B): if a != b: ok = False break return seq if ok else None else: for n in list(nums.keys()): if nums[n] > 0: tmpA = A.copy() tmpSeq = seq.copy() tmpNums = nums.copy() tmpA.insert(n-1,n) tmpSeq.append(n) tmpNums[n] -= 1 ans = dfs(N, B, tmpA, tmpSeq, tmpNums) if ans: return ans N = int(eval(input())) B = list(map(int, input().split())) ok = True nums = {b:0 for b in B} for i, b in enumerate(B): if i+1<b: ok = False break nums[b] += 1 if ok: for n in dfs(N,B,[],[],nums): print(n) else: print((-1))
import sys sys.setrecursionlimit(10**5) N = int(eval(input())) B = list(map(int, input().split())) ans = [] while len(B) > 0: ok = False for i in reversed(list(range(len(B)))): if B[i] == i+1: ok = True ans.append(B.pop(i)) break if not ok: break if len(B) > 0: print((-1)) else: for a in reversed(ans): print(a)
p03089
import copy import queue def main(): N = int(eval(input())) B = [int(i) for i in input().split()] q = queue.Queue() q.put((B, [])) def bfs(arr, indexes): if len(arr) == 0: return indexes for i in range(len(arr)): if i+1 == arr[i]: _indexes = copy.copy(indexes) _indexes.append(i) q.put((arr[:i] + arr[i+1:], _indexes)) return False while not q.empty(): item = q.get() res = bfs(item[0], item[1]) if res: for i in reversed(res): print((i+1)) return print((-1)) return main()
import copy N = int(eval(input())) B = [int(i) for i in input().split()] def dfs(arr, indexes): if len(arr) == 0: return indexes for i in range(len(arr)): if i+1 == arr[i]: _indexes = copy.copy(indexes) _indexes.append(i) res = dfs(arr[:i] + arr[i+1:], _indexes) if res: return res return False res = dfs(B, []) if res: for i in reversed(res): print((i+1)) else: print((-1))
p03089
import bisect,collections,copy,heapq,itertools,math,string import sys def I(): # 1 line 1 int return int(sys.stdin.readline().rstrip()) def LI(): # 1 line n ints return list(map(int,sys.stdin.readline().rstrip().split())) def S(): # 1 line 1 string return sys.stdin.readline().rstrip() def LS(): # 1 line n strings return list(sys.stdin.readline().rstrip().split()) C1 = S() C2 = S() if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]: print("YES") else: print("NO")
import bisect,collections,copy,heapq,itertools,math,string import sys def I(): # 1 line 1 int return int(sys.stdin.readline().rstrip()) def LI(): # 1 line n ints return list(map(int,sys.stdin.readline().rstrip().split())) def S(): # 1 line 1 string return sys.stdin.readline().rstrip() def LS(): # 1 line n strings return list(sys.stdin.readline().rstrip().split()) C1 = S() C2 = S() if C1[::-1] == C2: print("YES") else: print("NO")
p03555
s1=str(input()) s2=str(input()) print('YES') if s1==s2[::-1] else print('NO')
print('YES') if input()==input()[::-1] else print('NO')
p03555
import math from collections import defaultdict def is_prime(n: int)-> bool: if n == 2: return True if n < 2 or n % 2 == 0: return False # when n is a prime number # x^(n-1) ≡ 1 (mod n) return pow(2, (n-1), n) == 1 def prime_factorize(n: int): prime_factors = defaultdict(int) for i in range(2, int(math.sqrt(n)) + 1): if not is_prime(i): continue while True: div, mod = divmod(n, i) if mod == 0: prime_factors[i] += 1 n = div else: break if n == 1: break if n != 1: prime_factors[n] = 1 return prime_factors def main(): N, P = list(map(int, input().split())) prime_factors = prime_factorize(P) gcd = 1 for k, v in list(prime_factors.items()): v_cnt = v // N gcd *= pow(k, v_cnt) print(gcd) return main()
import math from collections import defaultdict def prime_factorize(n: int): prime_factors = defaultdict(int) for i in range(2, int(math.sqrt(n)) + 1): while True: div, mod = divmod(n, i) if mod == 0: prime_factors[i] += 1 n = div else: break if n == 1: break if n != 1: prime_factors[n] = 1 return prime_factors def main(): N, P = list(map(int, input().split())) prime_factors = prime_factorize(P) gcd = 1 for k, v in list(prime_factors.items()): v_cnt = v // N gcd *= pow(k, v_cnt) print(gcd) return main()
p03194
import sys N,P=[int(i) for i in input().split()] i=2 ans = 1 c=0 if N == 1: print(P) sys.exit() while P>1: if P%i==0: P//=i c+=1 if c==N: ans*=i c=0 else: c=0 i+=1 print(ans)
import sys N,P=[int(i) for i in input().split()] i=2 ans = 1 c=0 if N == 1: print(P) sys.exit() while P>i*i-4: if P%i==0: P//=i c+=1 if c==N: ans*=i c=0 else: c=0 i+=1 if P==i and c+1 ==N: ans*=i print(ans)
p03194
n,p=list(map(int,input().split())) if n==1: print(p) else: x=round((p**(1/n)+1))+1 for i in range(x,0,-1): if p%(i**n)==0: print(i) break
N, P = list(map(int, input().split())) ans = 1 if N >= 45: print(ans) elif N == 1: print(P) else: i = 1 while(i**N <= P): if P % (i**N) == 0: ans = i i += 1 print(ans)
p03194
N, P = list(map(int, input().split())) ans = 1 if N >= 45: print(ans) elif N == 1: print(P) else: i = 1 while(i**N <= P): if P % (i**N) == 0: ans = i i += 1 print(ans)
n,p=list(map(int,input().split())) if n==1: print(p) elif n>45: print((1)) else: x=round((p**(1/n)+1))+1 for i in range(x,0,-1): if p%(i**n)==0: print(i) break
p03194
# -*- coding: utf-8 -*- """ Created on Mon Dec 31 14:30:45 2018 @author: Yamazaki Kenichi """ N,P = list(map(int, input().split())) limit = int(pow(P,1/N)//1+1) if N == 1: ans = P else: ans = 1 for i in range(2,limit+1): if P % pow(i,N) == 0: ans = i print(ans)
# -*- coding: utf-8 -*- """ Created on Mon Dec 31 14:30:45 2018 @author: Yamazaki Kenichi """ N,P = list(map(int, input().split())) limit = int(pow(P,1/N)//1) if N == 1: ans = P elif limit == 1: ans = 1 else: ans = 1 for i in range(2,limit+2): if P % pow(i,N) == 0: ans = i print(ans)
p03194
import math n,p=list(map(int,input().split())) def C(N,P): if N == 1: return P a=math.ceil((P**(1/N)))+2 res=1 for i in range(2,a): if P % i**N == 0 : res = i return res print((C(n,p)))
n,p = list(map(int,input().split())) i = a = o = 1 m = round(p**(1/n)) for i in range(m,0,-1): a = i**n if p%a==0: print(i) exit()
p03194
n,p=list(map(int,input().split())) i=1 gcd=1 if(n==1): print(p) else: while((i**n)<=p): if(p%(i**n)==0): gcd=i i+=1 print(gcd)
n,p=list(map(int,input().split())) i=2 gcd=1 if(n>40): print((1)) elif(n==1): print(p) else: while((i**n)<=p): if(p%(i**n)==0): #print(i) gcd*=i p/=(i**n) i-=1 i+=1 print(gcd)
p03194
from math import floor n, p = list(map(int, input().split())) if n == 1: print(p) else: for i in range(1, floor(p**(1/n))+2): if p % i**n ==0: res = i print(res)
n, p = list(map(int, input().split())) if n == 1: print(p) else: for i in range(1, round(p**(1/n))+1): if p % i**n ==0: res = i print(res)
p03194
N, P = list(map(int, input().split())) if N == 1: print(P) exit() elif P == 1: print("1") exit() ans = 1 tmp = P for i in range(2, P): po = pow(i, N) while tmp % po == 0: tmp = tmp // po ans = ans * i # print(i, tmp, ans) if tmp < po: break print(ans)
N, P = list(map(int, input().split())) if N == 1: print(P) exit() elif P == 1: print("1") exit() ans = 1 tmp = P for i in range(2, int(pow(P, 1 / N)) + 1): po = pow(i, N) while tmp % po == 0: tmp = tmp // po ans = ans * i # print(i, tmp, ans) if tmp < po: break print(ans)
p03194
n, p = list(map(int, input().split())) if n == 1 or p== 1: print(p) exit() c2 = 0 while p%2 == 0: c2 += 1 p//=2 c = 2**(c2//n) i = int(p**(1/n))+1 while i > 1: if p%(i**n) == 0: print((c*i)) exit() else: i -= 1 print(c)
n, p = list(map(int, input().split())) if n == 1 or p== 1: print(p) exit() c2 = 0 while p%2 == 0: c2 += 1 p//=2 c = 2**(c2//n) i = int(p**(1/n))+1 if i%2 == 0: i -= 1 while i > 1: if p%(i**n) == 0: print((c*i)) exit() else: i -= 2 print(c)
p03194
import math N, P = list(map(int, input().split())) ProotN = pow(P, 1/N) # print(ProotN) for i in range(math.ceil(ProotN), 0, -1): if (P/i**N).is_integer(): print(i) break
def prime_decomposition(n): i = 2 dic = {} while i * i <= n: while n % i == 0: n /= i if i in dic: dic[i] += 1 else: dic[i] = 1 i += 1 if n > 1: dic[int(n)] = 1 return dic N, P = list(map(int, input().split())) d = prime_decomposition(P) ret = 1 for k, v in list(d.items()): if v >= N: ret *= k ** (v//N) print(ret)
p03194
# -*- coding: utf-8 -*- def main(): from math import sqrt n, p = list(map(int, input().split())) ans = 1 numbers = set() for i in range(1, int(sqrt(p)) + 1): a, b = divmod(p, i) if b == 0: numbers.add(i) numbers.add(a) for number in numbers: c, d = divmod(p, number ** n) if d == 0 and number ** n <= p: ans = max(ans, number) print(ans) if __name__ == '__main__': main()
# -*- coding: utf-8 -*- def run_prime_factorization(max_number: int): from math import sqrt ans = dict() remain = max_number for j in range(2, int(sqrt(max_number)) + 1): if remain % j == 0: count = 0 while remain % j == 0: count += 1 remain //= j ans[j] = count if remain != 1: ans[remain] = 1 return ans def main(): n, p = list(map(int, input().split())) ans = 1 # See: # https://www.youtube.com/watch?v=z0bIhkaSXY4 results = run_prime_factorization(p) for base, exponent in list(results.items()): ans *= base ** (exponent // n) print(ans) if __name__ == '__main__': main()
p03194
import math def read(): N, P = list(map(int, input().strip().split())) return N, P def solve(N, P): v3 = math.floor(P**(1/N)) + 1 for v in range(v3, 0, -1): if P % (v**N) == 0: return v return 1 if __name__ == '__main__': inputs = read() print((solve(*inputs)))
import math def read(): N, P = list(map(int, input().strip().split())) return N, P def solve(N, P): # problem constraint if N >= 40: return 1 # solve v3 = math.floor(P**(1/N)) + 1 for v in range(v3, 0, -1): if P % (v**N) == 0: return v return 1 if __name__ == '__main__': inputs = read() print((solve(*inputs)))
p03194
n, p = list(map(int, input().split())) out=1 tm = int(pow(p, 1/n)) for i in range(2,tm+1): if i==2: while p%(i**n)==0: p = p//(i**n) out *= i elif i==3: while p%(i**n)==0: p = p//(i**n) out *= i elif i%2!=0 and i%3!=0: while p%(i**n)==0: p = p//(i**n) out *= i if p < i**n: break print(out)
n, p = list(map(int, input().split())) if n==1: print(p) else: out=1 tm = int(pow(p, 1/n)) for i in range(2,tm+1): while p%(i**n)==0: p = p//(i**n) out *= i if p < i**n: break print(out)
p03194
import functools import operator N,P = list(map(int,input().split())) i = 2 res = [] if N == 1: print(P) elif P == 1: print((1)) else: while i <= P**1/N: while P % i**N == 0: P /= i**N res.append(i) else: if i == 2: i += 1 else: i += 2 res.append(1) result = functools.reduce(operator.mul, res) print(result) exit()
N,P = list(map(int,input().split())) i = round(P**(1/N)) res = [] if N == 1: print(P) elif P == 1: print((1)) else: for i in range(i,0,-1): if P%i**N==0: print(i) break
p03194
n,p = list(map(int,input().split())) if n == 1: print(p) exit() if n >=40: print((1)) exit() i =2 ans =1 while i**n <= p: if p%(i**n)==0: ans *= i p =p//(i**n) else: i += 1 print(ans)
n,p = list(map(int,input().split())) if n == 1: print(p) exit() if n >=40 or p==1: print((1)) exit() i =2 ans =1 while i**n <= p: if p%(i**n)==0: ans *= i p =p//(i**n) elif i==2: i+=1 else: i+=2 print(ans)
p03194
n,p = list(map(int,input().split())) if n == 1: print(p) exit() if n >=40 or p==1: print((1)) exit() i =2 ans =1 while i**n <= p: if p%(i**n)==0: ans *= i p =p//(i**n) elif i==2: i+=1 else: i+=2 print(ans)
N,P = list(map(int,input().split())) ans=1 i=2 if N==1: print(P) exit() if N>=40 or P==1: print((1)) exit() while i**N<=P: while P%(i**N) == 0: ans *= i P = P//(i**N) if i==2: i+=1 else: i+=2 print(ans)
p03194
from collections import Counter def d(P): c = Counter() i = 2 while (P > 1): if P % i == 0: c.update([i]) P //= i i -= 1 i += 1 return c def solve(N, P): c = d(P) ans = 1 for k in [k for k, v in list(c.items()) if v >= N]: ans *= k ** (c[k] // N) return ans if __name__ == "__main__": N, X = tuple(map(int, input().split(" "))) print((solve(N, X)))
from collections import Counter def d(P): c = Counter() i = 2 while (P > 1): if P % i == 0: c.update([i]) P //= i i -= 1 i += 1 if i > P ** 0.5: c.update([P]) break return c def solve(N, P): c = d(P) ans = 1 for k in [k for k, v in list(c.items()) if v >= N]: ans *= k ** (c[k] // N) return ans if __name__ == "__main__": N, X = tuple(map(int, input().split(" "))) print((solve(N, X)))
p03194
n,p=list(map(int,input().split())) if n==1: print(p) else: ans=1 for i in range(1,int(p**(1/n))+2): tmp=i**n if (p>=tmp) and (p%tmp == 0): ans=i if(p<tmp): break print(ans)
n,p=list(map(int,input().split())) def factorize(n): fct = [] # prime factor b, e = 2, 0 # base, exponent while b * b <= n: while n % b == 0: n = n // b e = e + 1 if e > 0: fct.append((b, e)) b, e = b + 1, 0 if n > 1: fct.append((n, 1)) return fct kekka=factorize(p) ans=1 for i in range(len(kekka)): ans=ans* kekka[i][0] ** (kekka[i][1]//n) print(ans)
p03194
n,p = list(map(int,input().split())) ans = 1 x = int(p ** (1/n)) +1 while x > 1: y = x ** n if p % y == 0: p //= y ans *= x else: x -= 1 print(ans)
n,p = list(map(int,input().split())) ans = 1 x = int(p ** (1/n)) while x > 1: y = x ** n if p % y == 0: p //= y ans *= x if p == 1: break else: x -= 1 print(ans)
p03194
N,P = list(map(int,input().split())) c = int(P**(1/N))+1 def is_prime(q): q = abs(q) if q == 2: return True if q < 2 or q&1 == 0: return False return pow(2, q-1, q) == 1 if N>1 and is_prime(P): print((1)) exit() while(1): if P%(c**N)==0: print(c) exit() c-=1
N,P = list(map(int,input().split())) r = round(P**(1/N)) for i in range(r,0,-1): if P%(i**N)==0: print(i) exit()
p03194
N, P = list(map(int, input().split())) import math g = 1 if N ==1: print(P) else: for i in range(1,math.ceil(P**(1/N))+1): X = i**N if X > P: break else: if P % X == 0: g = i print(g)
N, P = list(map(int, input().split())) import math g = 1 if N ==1: print(P) else: for i in range(1,int((P+1)**(1/N))+1): X = i**N if X > P: break else: if P % X == 0: g = i print(g)
p03194
import math n,p = list(map(int,input().split())) tmp = math.sqrt(p) if n == 1: print(p) else: for i in range(1,int(tmp)+1): if p % (i ** n) == 0: ans = i print(ans)
import math n,p = list(map(int,input().split())) tmp = math.sqrt(p) if n == 1: print(p) elif n >=100: print((1)) else: for i in range(1,int(tmp)+1): if p % (i ** n) == 0: ans = i print(ans)
p03194
import math n, p=list(map(int,input().split())) ans = 0 if n != 1: for i in range(1,int(math.sqrt(p+1))+1): ni = i**n if p/ni >= 1 and p/ni == int(p/ni): ans = i elif p/ni < 1: break print(ans) else: print(p)
n, p=list(map(int,input().split())) ans = 0 if n != 1: for i in range(1,int((p+1)**(1/n))+1): ni = i**n if p/ni >= 1 and p/ni == int(p/ni): ans = i elif p/ni < 1: break print(ans) else: print(p)
p03194
import math if __name__ == "__main__": n, p = list(map(int, input().split())) res = 1 sup = math.ceil(p ** (1 / n)) i = 2 while(i <= sup and i <= p): if p % i == 0: k = 1 p /= i while(p % i == 0): p /= i k += 1 if k >= n: for s in range(k // n): res *= i i += 1 print(res)
import math if __name__ == "__main__": n, p = list(map(int, input().split())) if n == 1: print(p) else: res = 1 sup = math.ceil(p ** (1 / n)) i = 2 while(i <= sup and i <= p): if p % i == 0: k = 1 p /= i while(p % i == 0): p /= i k += 1 if k >= n: for s in range(k // n): res *= i i += 1 print(res)
p03194
N, P = list(map(int, input().split())) ans = 0 if N == 1: print(P) else: for i in range(1, int(P**(1/N)+5)): if P % i**N == 0: ans = i print(ans)
N, P = list(map(int, input().split())) ans = 0 if N == 1: print(P) elif N >= P or N > 50: print((1)) else: for i in range(1, int(P**(1/N)+2)): if P % i**N == 0: ans = i print(ans)
p03194
N, P = list(map(int, input().split())) from math import sqrt from collections import Counter def is_prime(n): if n == 1: return False if n == 2: return True for i in range(2, int(sqrt(n))+1): if n % i == 0: return False return True def prime_factorization(n): #if is_prime(n):return [n] factor = [] f = 2 while n > 1: if n % f == 0: factor.append(f) n /= f else: f += 1 return factor p = prime_factorization(P) c = Counter(p) l = [] j = [] for k, v in list(c.items()): if N <= v: l.append(k) j.append(v//N) ans = 1 for i,v in zip(l,j): ans *= i**v print(ans)
from collections import Counter N, P = list(map(int, input().split())) def prime_factorization(n): factor = [] f = 2 while f ** 2 <= n: if n % f == 0: factor.append(f) n //= f else: f += 1 if n > 1: factor.append(n) return factor p = prime_factorization(P) c = Counter(p) l = [] j = [] for k, v in list(c.items()): if N <= v: l.append(k) j.append(v//N) ans = 1 for i,v in zip(l,j): ans *= i**v print(ans)
p03194
# -*- coding: utf-8 -*- from sys import stdin n,x = [int(i) for i in stdin.readline().split()] limit = int(x ** (1.0/n)) + 1 def factorize(x): ans = 1 p = 2 if x % p == 0: count = 1 x /= p while x % p == 0: count += 1 x /= p if count >= n: ans = ans * (p ** (count // n)) for p in range(3, limit, 2): if x % p == 0: count = 1 x /= p while x % p == 0: count += 1 x /= p if count >= n: ans = ans * (p ** (count // n)) if x < p * p: break return ans if x == 1: print((1)) elif n == 1: print(x) else: ans = factorize(x) print(ans)
# -*- coding: utf-8 -*- from sys import stdin n,x = [int(i) for i in stdin.readline().split()] limit = int(x ** (1.0/n)) + 1 def devide_counter(x, p): count = 1 x = x // p while x % p == 0: count += 1 x = x // p return x, count def factorize(x): ans = 1 p = 2 if x % p == 0: x, count = devide_counter(x, p) if count >= n: ans = ans * (p ** (count // n)) for p in range(3, limit, 2): if x % p == 0: x, count = devide_counter(x, p) if count >= n: ans = ans * (p ** (count // n)) if x < p * p: break return ans if x == 1: print((1)) elif n == 1: print(x) else: ans = factorize(x) print(ans)
p03194
n,p=list(map(int,input().split())) a=[i for i in range(int(p**(1/n))+1)] a[1]=0 b=int(p**0.5) for j in a: if j>b: break elif j==0: continue for k in range(2*j,len(a),j): a[k]=0 c=[l for l in a if l!=0] for m in range(len(c)): d=0 while p%c[m]==0: p//=c[m] d+=1 c[m]=[c[m],d] e=1 for v in c: e*=v[0]**(v[1]//n) print(e)
n,p=list(map(int,input().split())) if n==1: print(p) quit() a=[i for i in range(int(p**(1/n))+1)] a[1]=0 b=int(p**0.5) for j in a: if j>b: break elif j==0: continue for k in range(2*j,len(a),j): a[k]=0 c=[l for l in a if l!=0] for m in range(len(c)): d=0 while p%c[m]==0: p//=c[m] d+=1 c[m]=[c[m],d] e=1 for v in c: e*=v[0]**(v[1]//n) print(e)
p03194
a,b=list(map(int ,input().split())) x=int(pow(b,1/a)) x+=1 while x>=1: if b%(x**a)==0: print(x) exit() x-=1
a,b=list(map(int ,input().split())) x=int(pow(b,1/a)+0.00001) while x>=1: if b%(x**a)==0: print(x) exit() x-=1
p03194
n,p=list(map(int,input().split())) if n==1: print(p) else: d=int(p**(1/n)) k=1 for i in range(d+1,0,-1): if p%(i**n)==0: k=i print(k) break else: print(k)
n,p=list(map(int,input().split())) if n==1: print(p) else: def r(n,p): d=int(p**(1/n)) k=1 for i in range(1,d+1): if p%(i**n)==0: k=i return k c=1 while r(n,p)!=1: s=r(n,p) c*=s p=p/(s**n) print(c)
p03194
n,p=list(map(int, input().split())) ans=1 m=int(pow(p,1/n))+1 if n==0: print(p) else: m=int(pow(p,1/n))+1 i=2 c=0 while(i<=p and i<=m): #print('i,p=',i,p) if p % i == 0: p=p/i c=c+1 if p % i != 0: #print('i**(c//n)=',i**(c//n)) ans = ans * ( i**(c//n) ) i=i+1 c=0 else: i=i+1 print(ans)
n,p=list(map(int,input().split())) if n==1: print(p) exit() a=1 for i in range(2,int(p**0.5)+2): if p%i==0: c=0 while p%i==0: p//=i c+=1 a*=max(i**(c//n),1) if p==1: break print(a)
p03194
from collections import Counter def prime_factor(n): res = Counter() for i in range(2, int(n**.5) + 1): while n % i == 0: res[i] += 1 n //= i if n != 1: res[n] += 1 return res N, P = list(map(int, input().split())) cnt = prime_factor(P) ans = 1 for f in cnt: if cnt[f] >= N: ans *= f ** (cnt[f] // N) print(ans)
from collections import Counter def prime_factorize_fast(n, res=Counter()): while n % 2 == 0: res[2] += 1 n //= 2 while n % 3 == 0: res[3] += 1 n //= 3 d = 5 step = 2 while d <= int(n ** .5): while n % d == 0: res[d] += 1 n //= d d += step step = 6 - step if n != 1: res[n] += 1 return res N, P = list(map(int, input().split())) cnt = prime_factorize_fast(P) ans = 1 for f in cnt: if cnt[f] >= N: ans *= f ** (cnt[f] // N) print(ans)
p03194
N,P=list(map(int,input().split())) maxfac = int(P**(1/N)) # print(range(1,maxfac+1)) if N==1: print(P) exit() for i in range(1,maxfac+2)[::-1]: p = i**N # print(P%p) if P%p == 0: print(i) break
N,P=list(map(int,input().split())) maxfac = int(P**(1/N)) # print(range(1,maxfac+1)) if N==1: print(P) exit() elif N > 10**6: print((1)) exit() for i in range(1,maxfac+2)[::-1]: p = i**N # print(P%p) if P%p == 0: print(i) break
p03194
N,P=list(map(int,input().split())) maxfac = int(P**(1/N)) # print(range(1,maxfac+1)) if N==1: print(P) exit() elif N > 10**6: print((1)) exit() for i in range(1,maxfac+2)[::-1]: p = i**N # print(P%p) if P%p == 0: print(i) break
N,P=list(map(int,input().split())) maxfac = round(P**(1/N)) # print(range(1,maxfac+1)) if N==1: print(P) exit() for i in range(1,maxfac+1)[::-1]: p = i**N # print(P%p) if P%p == 0: print(i) break
p03194
from operator import itemgetter import collections N, P = list(map(int, input().split())) factor = collections.defaultdict(int) p = 2 n = P while n > 1: while n % p == 0: factor[p] += 1 n //= p p += 1 ans = 1 for key, value in list(factor.items()): num = value while num >= N: ans *= key num -= N print(ans)
import math N, P = list(map(int, input().split())) for i in reversed(list(range(1, round(math.pow(P, 1 / N)) + 1))): if P % (i ** N) == 0: print(i) exit()
p03194
import math N, P = list(map(int, input().split())) max_value = math.floor(pow(P, 1/N)+1) ans = 1 if N == 1: ans = P else: for i in range(1, max_value+1): mod = i ** N if P % mod == 0: ans = i print(ans)
import math N, P = list(map(int, input().split())) max_value = round(pow(P, 1/N)) + 1 ans = 1 if N == 1: ans = P else: for i in range(1, max_value): mod = i ** N if P % mod == 0: ans = i print(ans)
p03194
import math N, P = list(map(int, input().split())) for i in range(int(math.pow(P, 1 / N)) + 1, 0, -1): if P % (i ** N) == 0: print(i) break
n, p = list(map(int, input().split())) if n == 1: print(p) else: for i in range(1, round(p**(1/n))+1): if p % i**n ==0: res = i print(res)
p03194
import math N, P = list(map(int, input().split())) for i in range(1, round(math.pow(P, 1 / N)) + 1): if P % (i ** N) == 0: now_max = i print(now_max)
import math N, P = list(map(int, input().split())) if N == 1: print(P) else: for i in range(1, round(math.pow(P, 1 / N)) + 1): if P % (i ** N) == 0: now_max = i print(now_max)
p03194
n, p = list(map(int, input().split())) if n == 1: print(p) else: ans = 1 g = 1 while pow(g, n) <= p: if p % pow(g, n) == 0: ans = max(ans, g) g += 1 print(ans)
def prime_factor(n): ret = {} p = 2 while p*p <= n: while n % p == 0: ret[p] = ret.get(p, 0) + 1 n //= p p += 1 if n != 1: ret[n] = 1 return ret n, p = list(map(int, input().split())) primes = prime_factor(p) ans = 1 for p, e in list(primes.items()): ans *= max(1, p**(e//n)) print(ans)
p03194
import sys input = sys.stdin.readline n, p = list(map(int, input().split())) if n == 1: ans = p else: ans = 1 for i in range(2, 10**6+1): check = i**n if check > p: break elif p % check == 0: ans = i print(ans)
import sys input = sys.stdin.readline n, p = list(map(int, input().split())) if n == 1: ans = p elif n > 10**6: ans = 1 else: ans = 1 for i in range(2, 10**6+1): check = i**n if check > p: break elif p % check == 0: ans = i print(ans)
p03194
(N,P) = list(map(int,input().split())) if N == 1: print(P) exit() primelist=[] powerlist=[] p=2 while 1: Q = p**N if P < Q: break elif P == Q: primelist.append(p) powerlist.append(1) break # elif p**(N+1) > P: # p = P**(1/N) # if p == int(p): # primelist.append(int(p)) # powerlist.append(1) # break # f = 0 # for q in primelist: # if p % q == 0: # f = 1 # break # if f == 1: # p += 1 # continue # else: k = 0 while P % p == 0: P //= p k += 1 primelist.append(p) powerlist.append(k//N) p += 1 ans = 1 for i in range(len(primelist)): ans *= (primelist[i]**powerlist[i]) print(ans)
import math (N,P) = list(map(int,input().split())) if N == 1: print(P) exit() ans = 1 p = 2 logP = math.log(P) while N * math.log(p) <= logP: k = 0 while P % p == 0: P //= p k += 1 ans *= p**(k//N) if k > 0: logP = math.log(P) r = p % 6 if r == 1: p += 4 elif r == 5: p += 2 else: p += 1 print(ans)
p03194
n, p = [int(i) for i in input().split()] num = int(p ** (1 / n)) + 1 for i in range(num): pp = p dv = num - i if pp % (dv**n) == 0: ans = dv break print(ans)
n, p = [int(i) for i in input().split()] if n >= 10 ** 4: print((1)) exit() num = int(p ** (1 / n)) + 1 for i in range(num): pp = p dv = num - i if pp % (dv ** n) == 0: ans = dv break print(ans)
p03194
from statistics import mean, median,variance,stdev import sys import math import fractions def j(a): if a: print("AC") else :print("WA") def ct(x,y): if (x>y):print("") elif (x<y): print("") else: print("") def ip(): return int(eval(input())) #x = ip() #入力整数1つ x,y = (int(i) for i in input().split()) #入力整数横2つ #x,y,z = (int(i) for i in input().split()) #入力整数横3つ #n,m,x,y= (int(i) for i in input().split()) #入力整数横4つ #a = [int(i) for i in input().split()] #入力整数配列 #a = input() #入力文字列 #a = input().split() #入力文字配列 max = 1 ls = int(math.sqrt(y))+1 s = [] if y==1 or x>=y:print((1)) elif x==1:print(y) else: n = y for i in range(2,y//2+1): if n==1:break l=0 while n%i == 0: n = n//i l+=1 s.append([i,l]) for i in range(len(s)): s[i][1]//=x num = 1 for i in range(len(s)): if s[i][1]: num*=(pow(s[i][0],s[i][1])) print(num)
from statistics import mean, median,variance,stdev import sys import math import fractions def j(a): if a: print("AC") else :print("WA") def ct(x,y): if (x>y):print("") elif (x<y): print("") else: print("") def ip(): return int(eval(input())) #x = ip() #入力整数1つ x,y = (int(i) for i in input().split()) #入力整数横2つ #x,y,z = (int(i) for i in input().split()) #入力整数横3つ #n,m,x,y= (int(i) for i in input().split()) #入力整数横4つ #a = [int(i) for i in input().split()] #入力整数配列 #a = input() #入力文字列 #a = input().split() #入力文字配列 max = 1 ls = int(math.sqrt(y))+1 s = [] if y==1 or x>=y:print((1)) elif x==1:print(y) else: n = y for i in range(2,ls): if n==1:break l=0 while n%i == 0: n = n//i l+=1 s.append([i,l]) for i in range(len(s)): s[i][1]//=x num = 1 for i in range(len(s)): if s[i][1]: num*=(pow(s[i][0],s[i][1])) print(num)
p03194
n,p = list(map(int,input().split())) if n == 1: print(p) exit() a = 1 for i in range(1,1000001): if p< i**n: break if p%(i ** n) == 0: a = i print(a)
n,p = list(map(int,input().split())) if n == 1: print(p) exit() a = 1 for k in range(2,1000001): c = 0 while p%k == 0: p = p//k c += 1 a *= k**(c//n) if p == 1: break print(a)
p03194
N,P = list(map(int, input().split())) count = 1 ans = 0 if N > 1000001: print((1)) exit() while True: if count**N > P: break if P % count**N == 0: ans = count count += 1 print(ans)
N,P = list(map(int, input().split())) count = 1 ans = 0 if N == 1: print(P) exit() if N > 1000001: print((1)) exit() while True: if count**N > P: break if P % count**N == 0: ans = count count += 1 print(ans)
p03194
import math N,P = list(map(int,input().split())) if N == 1: print(P) exit() ans = 1 for i in range(2,math.floor(pow(P,1/2)) + 1): if P % i == 0: count = 1 P = P // i while P % i == 0: count += 1 P = P // i ans *= pow(i,count // N) print(ans)
import math def factoring(n,dict_count = {}): sup = math.floor(pow(n,1/2)) n_new = n for i in range(2,sup + 1): if n % i == 0: n_new = n // i if i in dict_count: dict_count[i] += 1 else: dict_count[i] = 1 break if n == n_new: if n_new in dict_count: dict_count[n_new] += 1 else: dict_count[n_new] = 1 return sorted(list(dict_count.items())) return factoring(n_new,dict_count) N,P = list(map(int,input().split())) result = factoring(P) ans = 1 for e in result: ans *= pow(e[0],e[1] // N) print(ans)
p03194
from collections import defaultdict from copy import deepcopy N,K=list(map(int,input().split())) AB=[0]*N dic=defaultdict(int) for i in range(N): a,b=list(map(int,input().split())) if a in list(dic.keys()): AB[dic[a]]=[a,AB[dic[a]][1]+b] else: dic[a]=i AB[i]=[a,b] AB_=[] for i in AB: if i==0: continue k=bin(i[0])[2:].zfill(30) AB_.append([k,i[1]]) AB=AB_ l=len(AB) k=bin(K)[2:].zfill(30) ans=0 for i in range(30): if k[i]=="1": t=k[:i]+"0" sum=0 for j in range(l): if int(t)|int(AB[j][0][:i+1])<=int(t): sum+=AB[j][1] ans=max(ans,sum) sum=0 t=k for j in range(l): if int(t)|int(AB[j][0])<=int(t): sum+=AB[j][1] ans=max(ans,sum) print(ans)
N,K=list(map(int,input().split())) AB=[] for i in range(N): a,b=list(map(int,input().split())) AB.append([a,b]) ans=sum([b for a,b in AB if K|a==K]) for i in range(int.bit_length(K)-1,0,-1): if not K &(1<<i): continue m=K & ~(1<<i)|(1<<i)-1 s=sum([b for a,b in AB if m | a ==m]) ans=max(s,ans) print(ans)
p03590
import sys readline=sys.stdin.readline read=sys.stdin.read def main(): n,k=list(map(int,readline().split())) ab=[list(map(int,l.split())) for l in read().splitlines()] ek=0 while k>>ek: ek+=1 ans=0 for i in range(ek): if k>>i&1: m=(k>>(i+1))<<(i+1)|((1<<i)-1) ans=max(ans,sum(e[1] for e in ab if e[0]|m==m)) ans=max(ans,sum(e[1] for e in ab if e[0]|k==k)) print(ans) if __name__=='__main__': main()
import sys readline=sys.stdin.readline read=sys.stdin.read def main(): n,k=list(map(int,readline().split())) ab=[list(map(int,l.split())) for l in read().splitlines()] ek=0 while k>>ek: ek+=1 ans=0 for i in range(ek): if k>>i&1: m=(k>>(i+1))<<(i+1)|((1<<i)-1) ans=max(ans,sum((e[1] for e in ab if e[0]|m==m))) ans=max(ans,sum((e[1] for e in ab if e[0]|k==k))) print(ans) if __name__=='__main__': main()
p03590
from collections import Counter def func(n): dic = Counter() rest = list({i ** 2 % n for i in range(1, n)}) lenr = len(rest) rest.sort() half = n // 2 for i in range(lenr): resti = rest[i] for j in range(i + 1, lenr): dff = rest[j] - resti if dff > half: dic[n - dff] += 2 else: dic[dff] += 2 for i in range(1, half + 1): print((dic[i])) def main(): while True: n = int(eval(input())) if n == 0: break func(n) main()
import itertools def func(n): rest = {i ** 2 % n for i in range(1, n)} count = [0] * n for x, y in itertools.combinations(rest, 2): count[x - y] += 2 for i in range(n // 2): print((count[i + 1] + count[n - i - 1])) def main(): while True: n = int(eval(input())) if n == 0: break func(n) main()
p00142
# 0142 - Nature of Prime Numbers while True: n = int(eval(input())) if n == 0: break _min = 0 _max = int((n - 1) / 2) ns = set([ x * x % n for x in range(1, n)]) count = [0 for i in range(0, int((n - 1) / 2) + 1)] for i in ns: for j in ns: if i < j: m = i - j if m < _min: m = n + m if m > _max: m = n - m count[m] += 1 for i in count: if i > 0: print((i * 2))
# 0142 - Nature of Prime Numbers while True: n = int(eval(input())) if n == 0: break _max = int((n - 1) / 2) ns = set([ x * x % n for x in range(1, n)]) count = [0 for i in range(0, int((n - 1) / 2) + 1)] for i in ns: for j in ns: if i > j: m = i - j if m > _max: m = n - m count[m] += 1 for i in count: if i > 0: print((i * 2))
p00142
n=int(eval(input())) a=list(map(int,input().split())) b=list(map(int,input().split())) cta=[0]*(n) ctb=[0]*(n) for i in range(n): cta[a[i]-1]+=1 ctb[b[i]-1]+=1 for i in range(n): if cta[i]+ctb[i]>n: print('No') exit() sa=[0] sb=[0] for i in range(n): sa.append(cta[i]+sa[-1]) sb.append(ctb[i]+sb[-1]) l=[] for i in range(n): l.append(sa[i+1]-sb[i]) ans=[] for i in range(n): ans.append(str(b[(i-max(l))%n])) print('Yes') print((' '.join(ans)))
n=int(eval(input())) a=list(map(int,input().split())) b=list(map(int,input().split())) cta=[0]*n ctb=[0]*n for i in range(n): cta[a[i]-1]+=1 ctb[b[i]-1]+=1 for i in range(n): if cta[i]+ctb[i]>n: print('No') exit() sa=[0] sb=[0] for i in range(n): sa.append(cta[i]+sa[-1]) sb.append(ctb[i]+sb[-1]) l=[] for i in range(n): l.append(sa[i+1]-sb[i]) ans=[] maxl=max(l) for i in range(n): ans.append(str(b[(i-maxl)%n])) print('Yes') print((' '.join(ans)))
p02557
def main(): n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) ai, bi = 0, 0 al, bl = [], [] while ai < n and bi < n: ax, bx = a[ai], b[bi] la, lb = [], [] if ax == bx: cnt = 2 la.append(ai) ai += 1 while ai < n and a[ai] == ax: la.append(ai) cnt += 1 ai += 1 lb.append(bi) bi += 1 while bi < n and b[bi] == bx: lb.append(bi) cnt += 1 bi += 1 if cnt > n: print('No') exit() elif ax < bx: la.append(ai) ai += 1 else: lb.append(bi) bi += 1 al.append(la) bl.append(lb) print('Yes') slit = 0 for i in range(len(al)): if len(al[i]) == 0 or len(bl[i]) == 0: continue if al[i][-1] - bl[i][0] + 1 > slit: slit = al[i][-1] - bl[i][0] + 1 print((' '.join(map(str, b[n-slit:] + b[:n-slit])))) main()
# bを必要なだけ(strideの分)右にずらせばよい def main(): n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) ai, bi = 0, 0 stride = 0 while ai < n and bi < n: ax, bx = a[ai], b[bi] if ax == bx: cnt = 2 ai += 1 while ai < n and a[ai] == ax: cnt += 1 ai += 1 bi_copy = bi bi += 1 while bi < n and b[bi] == bx: cnt += 1 bi += 1 if cnt > n: print('No') exit() if stride < ai - bi_copy: stride = ai - bi_copy elif ax < bx: ai += 1 else: bi += 1 print('Yes') print((' '.join(map(str, b[n-stride:] + b[:n-stride])))) main()
p02557
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): import heapq from collections import defaultdict dd = defaultdict(int) N=I() A=LI() B=LI() cntA=[0]*(N+1) cntB=[0]*(N+1) for i in range(N): cntA[A[i]]+=1 cntB[B[i]]+=1 cnt=[0]*(N+1) # 合計がNより多いと無理 for i in range(N+1): v1=cntA[i] v2=cntB[i] if v1+v2>N: print("No") exit() cnt[i]=v1+v2 hqa=[] heapq.heapify(hqa) hqb=[] heapq.heapify(hqb) for i in range(N+1): if cntA[i]!=0: a=(-1*cntA[i],i)#回数*-1 , 値 heapq.heappush(hqa,a) if cntB[i]!=0: a=(-1*cntB[i],i)#回数*-1 , 値 heapq.heappush(hqb,a) L=[]#(aの値,bの値)を入れていく same=-1 while hqa: ca,a=heapq.heappop(hqa) cb,b=heapq.heappop(hqb) #違うのなら組にできる if a!=b: use=max(ca,cb) * -1 for _ in range(use): L.append((a,b)) ca+=use if ca!=0: heapq.heappush(hqa,(ca,a)) cb+=use if cb!=0: heapq.heappush(hqb,(cb,b)) else: if not hqb: #取り出せないなら #つまり,b側は残り1種類 use=ca*(-1) cb+=use heapq.heappush(hqb,(cb,b)) for _ in range(use): L.append((a,a)) same=a else: (cb2,b2)=heapq.heappop(hqb) heapq.heappush(hqb,(cb,b)) #使わなかったやつ返す use=max(ca,cb2) * -1 for _ in range(use): L.append((a,b2)) ca+=use if ca!=0: heapq.heappush(hqa,(ca,a)) cb2+=use if cb2!=0: heapq.heappush(hqb,(cb2,b2)) L.sort() ans=[0]*N samex=[] nots=[] for i in range(N): temp=L[i][1] ans[i]=temp if temp==same: samex.append(i) for i in range(N): if A[i]!=same: nots.append(i) if same!=-1: if len(nots)<len(samex): print("No") exit() for i in range(len(samex)):#入れ替える ans[samex[i]],ans[nots[i]] = ans[nots[i]], ans[samex[i]] now=0 aaa=0 for i in range(N): if ans[i]==A[i]: for jj in range(N-1,-1,-1): aaa+=1 j=(now+jj)%N if A[j]!=ans[i] and A[i]!=ans[j]: ans[i],ans[j] = ans[j],ans[i] now=j if aaa>=300000000: print("No") exit() print("Yes") print((' '.join(map(str, ans)))) main()
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): import heapq from collections import defaultdict dd = defaultdict(int) N=I() A=LI() B=LI() cntA=[0]*(N+1) cntB=[0]*(N+1) for i in range(N): cntA[A[i]]+=1 cntB[B[i]]+=1 cnt=[0]*(N+1) # 合計がNより多いと無理 for i in range(N+1): v1=cntA[i] v2=cntB[i] if v1+v2>N: print("No") exit() cnt[i]=v1+v2 hqa=[] heapq.heapify(hqa) hqb=[] heapq.heapify(hqb) for i in range(N+1): if cntA[i]!=0: a=(-1*cntA[i],i)#回数*-1 , 値 heapq.heappush(hqa,a) if cntB[i]!=0: a=(-1*cntB[i],i)#回数*-1 , 値 heapq.heappush(hqb,a) L=[]#(aの値,bの値)を入れていく same=-1 while hqa: ca,a=heapq.heappop(hqa) cb,b=heapq.heappop(hqb) #違うのなら組にできる if a!=b: use=max(ca,cb) * -1 for _ in range(use): L.append((a,b)) ca+=use if ca!=0: heapq.heappush(hqa,(ca,a)) cb+=use if cb!=0: heapq.heappush(hqb,(cb,b)) else: if not hqb: #取り出せないなら #つまり,b側は残り1種類 use=ca*(-1) cb+=use heapq.heappush(hqb,(cb,b)) for _ in range(use): L.append((a,a)) same=a else: (cb2,b2)=heapq.heappop(hqb) heapq.heappush(hqb,(cb,b)) #使わなかったやつ返す use=max(ca,cb2) * -1 for _ in range(use): L.append((a,b2)) ca+=use if ca!=0: heapq.heappush(hqa,(ca,a)) cb2+=use if cb2!=0: heapq.heappush(hqb,(cb2,b2)) L.sort() ans=[0]*N samex=[] nots=[] for i in range(N): temp=L[i][1] ans[i]=temp if A[i]==same and ans[i]==same: samex.append(i) for i in range(N): if A[i]!=same and ans[i]!=same: nots.append(i) if same!=-1: # if len(nots)<len(samex): # print("No") # exit() for i in range(len(samex)):#入れ替える ans[samex[i]],ans[nots[i]] = ans[nots[i]], ans[samex[i]] now=0 aaa=0 for i in range(N): if ans[i]==A[i]: for j in range(N-1,-1,-1): aaa+=1 if A[j]!=ans[i] and A[i]!=ans[j]: ans[i],ans[j] = ans[j],ans[i] now=j if aaa>=100000000: print("No") exit() print("Yes") print((' '.join(map(str, ans)))) main()
p02557
import sys,queue,math,copy,itertools,bisect,collections,heapq def main(): LI = lambda : [int(x) for x in sys.stdin.readline().split()] NI = lambda : int(sys.stdin.readline()) N = NI() A = LI() B = LI() mb = B[-1] for i in range(N): if A[i] == B[i]: if B[i] < mb: p = bisect.bisect_left(B[i+1:],B[i]+1) + i+1 if p > N-1: print('No') return else: p = N-1 - i t = B[i] B[i] = B[p] B[p] = t if A[i] == B[i]: print('No') return print('Yes') print(*B,sep=' ') if __name__ == '__main__': main()
import sys,queue,math,copy,itertools,bisect,collections,heapq def main(): LI = lambda : [int(x) for x in sys.stdin.readline().split()] NI = lambda : int(sys.stdin.readline()) N = NI() A = LI() B = LI() c = collections.Counter() for x in A: c[x] += 1 for x in B: c[x] += 1 if c[x] > N: print('No') return s = 0 for i in range(N): if A[i] == B[i]: p = bisect.bisect_left(B,B[i]+1,i+1) if p > N-1: p = s s += 1 while B[i] == B[s]: s+=1 B[i],B[p] = B[p],B[i] print('Yes') print(*B,sep=' ') if __name__ == '__main__': main()
p02557
# 解説を参考に作成 # import sys # sys.setrecursionlimit(10 ** 6) # import bisect # from collections import deque # from decorator import stop_watch # # # @stop_watch def solve(N, Ai, Bi): Ci = [0] * (N + 1) Di = [0] * (N + 1) j = 0 k = 0 for i in range(1, N + 1): while j < N and Ai[j] <= i: j += 1 Ci[i] = j while k < N and Bi[k] <= i: k += 1 Di[i] = k # print(Ci) # print(Di) for i in range(1, N + 1): if Ci[i] - Ci[i - 1] + Di[i] - Di[i - 1] > N: print('No') return x = 0 for i in range(1, N + 1): x = max(x, Ci[i] - Di[i - 1]) print('Yes') # print(x) # print(' '.join([str(a) for a in Ai])) print((' '.join([str(Bi[(N - x + i) % N]) for i in range(N)]))) if __name__ == '__main__': # S = input() N = int(eval(input())) # N, M = map(int, input().split()) Ai = [int(i) for i in input().split()] Bi = [int(i) for i in input().split()] # ABi = [[int(i) for i in input().split()] for _ in range(N)] solve(N, Ai, Bi) # # test # from random import randint # from func import random_str # solve()
# 解説を参考に作成 # import sys # sys.setrecursionlimit(10 ** 6) # import bisect # from collections import deque # from decorator import stop_watch # # # @stop_watch def solve(N, A, B): buf = -1 key = 0 for i in range(N): if buf != A[i]: key = 0 # 前回(A[i - 1])と同じ値じゃなければリセット if A[i] == B[i]: for j in range(key, N): if A[i] != A[j] and B[j] != A[i]: B[i], B[j] = B[j], B[i] key = j break else: print('No') return buf = A[i] print('Yes') print((' '.join([str(i) for i in B]))) if __name__ == '__main__': # S = input() N = int(eval(input())) # N, M = map(int, input().split()) A = [int(i) for i in input().split()] B = [int(i) for i in input().split()] # ABi = [[int(i) for i in input().split()] for _ in range(N)] solve(N, A, B) # # test # from random import randint # from func import random_str # solve()
p02557
n=int(eval(input())) m=[0]*101 for i in range(1,n+1): for j in range(2,n+1): while i%j==0: a=i//j while (a+1)*j<=i: a+=1 i=a m[j]+=1 counter75=0 counter25=0 counter15=0 counter5=0 counter3=0 for i in range(101): if m[i]>=74: counter75+=1 if m[i]>=24: counter25+=1 if m[i]>=14: counter15+=1 if m[i]>=4: counter5+=1 if m[i]>=2: counter3+=1 a=(counter5*(counter5-1)*(counter3-2))//2 while (a+1)*2<=(counter5*(counter5-1)*(counter3-2)): a+=1 print((counter75+counter25*(counter3-1)+counter15*(counter5-1)+a))
import sys primes=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] num3=0 num5=0 num15=0 num25=0 num75=0 n=int(eval(input())) for i in primes: tmp=0 j=1 while n//pow(i,j)>0: tmp+=n//pow(i,j) j+=1 if tmp>=2: num3+=1 if tmp>=4: num5+=1 if tmp>=14: num15+=1 if tmp>=24: num25+=1 if tmp>=74: num75+=1 print((num75+max(0,(num3-1)*num25)+max(0,((num3-2)*(num5-1)*num5)//2)+max(0,((num5-1)*num15))))
p03213
# -*- coding: utf-8 -*- """ Created on Thu Jan 3 10:20:42 2019 @author: Yamazaki Kenichi """ N = int(eval(input())) prime = [2] for j in range(3,100): if all(j % i != 0 for i in prime) : prime.append(j) N1 = 1 for i in range(1,N+1): N1 *= i prime1 = [] a02,a04,a14,a24,a74 =0,0,0,0,0 for j in prime: temp = 0 while N1 % pow(j,temp) ==0: temp += 1 a02 += 1 if temp > 2 else 0 a04 += 1 if temp > 4 else 0 a14 += 1 if temp > 14 else 0 a24 += 1 if temp > 24 else 0 a74 += 1 if temp > 74 else 0 prime1.append(temp) ans = a74 +a24*(a02-1) +a14*(a04-1) +a04*(a04-1)//2*(a02-2) print(ans)
# -*- coding: utf-8 -*- """ Created on Thu Jan 3 10:20:42 2019 @author: Yamazaki Kenichi """ N = int(eval(input())) prime = [2] for j in range(3,100): if all(j % i != 0 for i in prime) : prime.append(j) N1 = 1 for i in range(1,N+1): N1 *= i prime1 = [] for j in prime: temp = 0 while N1 % pow(j,temp) ==0: temp += 1 prime1.append(temp-1) def num(m): return len(list([x for x in prime1 if x>=m-1])) ans = num(75)+ num(25)*(num(3)-1)+ num(15)*(num(5)-1)+ num(5)*(num(5)-1)//2*(num(3)-2) print(ans)
p03213
from math import factorial from itertools import permutations n=int(eval(input())) np=factorial(n) def eratosthenes(n): is_p=[1]*n p_list=[] is_p[0]=0 is_p[1]=0 for i in range(2,n): if is_p[i]: p_list.append(i) for j in range(i*i,n,i): is_p[j] = 0 return is_p, p_list lim=10**2+1 is_p, p_list=eratosthenes(lim) cnt=0 ans=[] l=len(p_list) for i in range(l): for j in range(i+1,l): for k in range(j+1,l): for s,t,u in permutations([p_list[i],p_list[j],p_list[k]],3): num1=(s**4)*(t**4)*(u**2) num2=(s**14)*(t**4) num3=(s**24)*(t**2) num4=s**74 for z in [num1,num2,num3,num4]: if np%z==0: ans.append(z) print((len(set(ans))))
from math import factorial from itertools import permutations def eratosthenes(n): is_p=[1]*n p_list=[] is_p[0]=0 is_p[1]=0 for i in range(2,n): if is_p[i]: p_list.append(i) for j in range(i*i,n,i): is_p[j] = 0 return is_p, p_list n=int(eval(input())) np=factorial(n) lim=10**2+1 is_p, p_list=eratosthenes(lim) ans=[] for s,t,u in permutations(p_list,3): num1=(s**4)*(t**4)*(u**2) num2=(s**14)*(t**4) num3=(s**24)*(t**2) num4=s**74 for z in [num1,num2,num3,num4]: if np%z==0: ans.append(z) print((len(set(ans))))
p03213
from math import factorial from itertools import permutations n=int(eval(input())) np=factorial(n) p_list=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] ans=[] for s,t,u in permutations(p_list,3): num1=(s**4)*(t**4)*(u**2) num2=(s**14)*(t**4) num3=(s**24)*(t**2) num4=s**74 for z in [num1,num2,num3,num4]: if np%z==0: ans.append(z) print((len(set(ans))))
from collections import Counter from itertools import permutations n=int(eval(input())) def factorization(n): p=2 fcr=[] while p*p<=n: while n%p==0: fcr.append(p) n//=p p+=1 if n>1: fcr.append(n) return fcr fcr_l=[] for i in range(1,n+1): fcr=factorization(i) fcr_l+=fcr c=Counter(fcr_l) fcr_st=set(fcr_l) ans=[] for p,q,r in permutations(fcr_st,3): if c[p]>=74: ans.append(p**74) if c[p]>=24 and c[q]>=2: ans.append((p**24)*(q**2)) if c[p]>=14 and c[q]>=4: ans.append((p**14)*(q**4)) if c[p]>=4 and c[q]>=4 and c[r]>=2: ans.append((p**4)*(q**4)*(r**2)) print((len(set(ans))))
p03213
import sys from collections import defaultdict read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline in_n = lambda: int(readline()) in_nn = lambda: list(map(int, readline().split())) in_nl = lambda: list(map(int, readline().split())) in_na = lambda: list(map(int, read().split())) in_s = lambda: readline().rstrip().decode('utf-8') def factorize_dict(n): b = 2 fct = defaultdict(lambda: 0) while b ** 2 <= n: while n % b == 0: n //= b fct[b] += 1 b += 1 if n > 1: fct[n] += 1 return fct def main(): N = in_n() if N == 1: print((0)) exit() prime = defaultdict(int) for i in range(1, N + 1): for k, v in list(factorize_dict(i).items()): prime[k] += v n2, n4, n14, n24, n74 = 0, 0, 0, 0, 0 for k, v in list(prime.items()): if v >= 2: n2 += 1 if v >= 4: n4 += 1 if v >= 14: n14 += 1 if v >= 24: n24 += 1 if v >= 74: n74 += 1 ans = n74 if n24 >= 1: ans += n24 * (n2 - 1) if n14 >= 1: ans += n14 * (n4 - 1) if n4 >= 2: ans += n4 * (n4 - 1) // 2 * (n2 - 2) print(ans) if __name__ == '__main__': main()
import sys from collections import defaultdict read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline in_n = lambda: int(readline()) in_nn = lambda: list(map(int, readline().split())) in_nl = lambda: list(map(int, readline().split())) in_na = lambda: list(map(int, read().split())) in_s = lambda: readline().rstrip().decode('utf-8') def factorize_dict(n): b = 2 fct = defaultdict(lambda: 0) while b ** 2 <= n: while n % b == 0: n //= b fct[b] += 1 b += 1 if n > 1: fct[n] += 1 return fct def main(): N = in_n() prime = defaultdict(int) for i in range(1, N + 1): for k, v in list(factorize_dict(i).items()): prime[k] += v def num(a): return len(list([x for x in list(prime.values()) if x >= a])) ans = num(74) if num(24) >= 1: ans += num(24) * (num(2) - 1) if num(14) >= 1: ans += num(14) * (num(4) - 1) if num(4) >= 2: ans += num(4) * (num(4) - 1) // 2 * (num(2) - 2) print(ans) if __name__ == '__main__': main()
p03213
import collections import functools import itertools import math import operator N = int(eval(input())) def get_prime_factorized(N): R = [] b, e = 2, 0 while b ** 2 <= N: while N % b == 0: N = N // b e += 1 if e > 0: R.append([b, e]) b, e = b + 1, 0 if N > 1: R.append([N, 1]) return R def n_C_r(n, r): return int(math.factorial(n) / math.factorial(r) / math.factorial(n-r)) if N > 9: L = [l[1]+1 for l in get_prime_factorized(math.factorial(N))] L = [[3, 5, 15, 25, 75] if l >= 75 else [3, 5, 15, 25] if l >= 25 else [3, 5, 15] if l >= 15 else [3, 5] if l >= 5 else [3] if l >= 3 else [1] for l in L] L = [l for l in L if l != [1]] L = list(itertools.chain.from_iterable(L)) C = collections.Counter(L) R = C[75] + n_C_r(C[5], 2) * n_C_r(C[3]-2, 1) + C[25] * (C[3] - 1) + C[15] * (C[5] - 1) print(R) else: print((0))
import collections import itertools import math N = int(eval(input())) def get_prime_factorized(N): R = [] b, e = 2, 0 while b ** 2 <= N: while N % b == 0: N = N // b e += 1 if e > 0: R.append([b, e]) b, e = b + 1, 0 if N > 1: R.append([N, 1]) return R def n_C_r(n, r): return int(math.factorial(n) / math.factorial(r) / math.factorial(n-r)) if N > 9: L = [l[1]+1 for l in get_prime_factorized(math.factorial(N))] L = [[3, 5, 15, 25, 75] if l >= 75 else [3, 5, 15, 25] if l >= 25 else [3, 5, 15] if l >= 15 else [3, 5] if l >= 5 else [3] if l >= 3 else [1] for l in L] L = [l for l in L if l != [1]] L = list(itertools.chain.from_iterable(L)) C = collections.Counter(L) R = C[75] + n_C_r(C[5], 2) * n_C_r(C[3]-2, 1) + C[25] * (C[3] - 1) + C[15] * (C[5] - 1) print(R) else: print((0))
p03213
from collections import defaultdict def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) for ai in a: dict[ai] += 1 N = int(eval(input())) dict = defaultdict(int) def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) for ai in a: dict[ai] += 1 for i in range(1, N + 1): prime_factorize(i) ans = 0 # p**4 * q**4 * r**2 for k1, v1 in list(dict.items()): for k2, v2 in list(dict.items()): for k3, v3 in list(dict.items()): if k1 < k2 < k3: if v1 >= 2 and v2 >= 4 and v3 >= 4: ans += 1 if v1 >= 4 and v2 >= 2 and v3 >= 4: ans += 1 if v1 >= 4 and v2 >= 4 and v3 >= 2: ans += 1 # p**14 * q**4 # p**24 * q*2 for k1, v1 in list(dict.items()): for k2, v2 in list(dict.items()): if k1 < k2: if v1 >= 14 and v2 >= 4: ans += 1 if v1 >= 4 and v2 >= 14: ans += 1 if v1 >= 24 and v2 >= 2: ans += 1 if v1 >= 2 and v2 >= 24: ans += 1 # p**74 for k1, v1 in list(dict.items()): if v1 >= 74: ans += 1 print(ans)
from collections import defaultdict N = int(eval(input())) dict = defaultdict(int) def prime_factorize(n): # nを素因数分解してdictに保存 a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) for ai in a: dict[ai] += 1 for i in range(1, N + 1): # N!の素因数分解に相当する prime_factorize(i) ans = 0 # p**4 * q**4 * r**2 for k1, v1 in list(dict.items()): for k2, v2 in list(dict.items()): for k3, v3 in list(dict.items()): if k1 < k2 < k3: if v1 >= 2 and v2 >= 4 and v3 >= 4: ans += 1 if v1 >= 4 and v2 >= 2 and v3 >= 4: ans += 1 if v1 >= 4 and v2 >= 4 and v3 >= 2: ans += 1 for k1, v1 in list(dict.items()): for k2, v2 in list(dict.items()): if k1 < k2: # p**14 * q**4 if v1 >= 14 and v2 >= 4: ans += 1 if v1 >= 4 and v2 >= 14: ans += 1 # p**24 * q*2 if v1 >= 24 and v2 >= 2: ans += 1 if v1 >= 2 and v2 >= 24: ans += 1 # p**74 for k1, v1 in list(dict.items()): if v1 >= 74: ans += 1 print(ans)
p03213
# -*- coding: utf-8 -*- import sys import math import os import itertools import string import heapq import _collections from collections import Counter from collections import defaultdict from functools import lru_cache import bisect import re import queue from decimal import * class Scanner(): @staticmethod def int(): return int(sys.stdin.readline().rstrip()) @staticmethod def string(): return sys.stdin.readline().rstrip() @staticmethod def map_int(): return [int(x) for x in Scanner.string().split()] @staticmethod def string_list(n): return [Scanner.string() for i in range(n)] @staticmethod def int_list_list(n): return [Scanner.map_int() for i in range(n)] @staticmethod def int_cols_list(n): return [Scanner.int() for i in range(n)] class Math(): @staticmethod def gcd(a, b): if b == 0: return a return Math.gcd(b, a % b) @staticmethod def lcm(a, b): return (a * b) // Math.gcd(a, b) @staticmethod def divisor(n): res = [] i = 1 for i in range(1, int(n ** 0.5) + 1): if n % i == 0: res.append(i) if i != n // i: res.append(n // i) return res @staticmethod def round_up(a, b): return -(-a // b) @staticmethod def is_prime(n): if n < 2: return False if n == 2: return True if n % 2 == 0: return False d = int(n ** 0.5) + 1 for i in range(3, d + 1, 2): if n % i == 0: return False return True def pop_count(x): x = x - ((x >> 1) & 0x5555555555555555) x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333) x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f x = x + (x >> 8) x = x + (x >> 16) x = x + (x >> 32) return x & 0x0000007f MOD = int(1e09) + 7 INF = int(1e15) def pm(X): res = {} for i in range(2, int(X ** 0.5) + 1): if X % i == 0: res[i] = 0 while X % i == 0: X //= i res[i] += 1 if X > 1: res[X] = 1 return res def solve(): N = Scanner.int() M = defaultdict(int) for i in range(2, N + 1): d = pm(i) for k, v in list(d.items()): M[k] += v ans = 0 for r in range(2, N + 1): for p in range(2, N+1): for q in range(p + 1, N + 1): if p == r: continue if q == r: continue if M[r] >= 2 and M[p] >= 4 and M[q] >= 4: ans += 1 for p in range(2, N + 1): if M[p] >= 74: ans += 1 for p in range(2, N + 1): for q in range(2, N+1): if p == q: continue if M[p] >= 14 and M[q] >= 4: ans += 1 if M[p] >= 24 and M[q] >= 2: ans += 1 print(ans) def main(): # sys.stdin = open("sample.txt") solve() if __name__ == "__main__": main()
# -*- coding: utf-8 -*- import sys import math import os import itertools import string import heapq import _collections from collections import Counter from collections import defaultdict from functools import lru_cache import bisect import re import queue from decimal import * class Scanner(): @staticmethod def int(): return int(sys.stdin.readline().rstrip()) @staticmethod def string(): return sys.stdin.readline().rstrip() @staticmethod def map_int(): return [int(x) for x in Scanner.string().split()] @staticmethod def string_list(n): return [Scanner.string() for i in range(n)] @staticmethod def int_list_list(n): return [Scanner.map_int() for i in range(n)] @staticmethod def int_cols_list(n): return [Scanner.int() for i in range(n)] class Math(): @staticmethod def gcd(a, b): if b == 0: return a return Math.gcd(b, a % b) @staticmethod def lcm(a, b): return (a * b) // Math.gcd(a, b) @staticmethod def divisor(n): res = [] i = 1 for i in range(1, int(n ** 0.5) + 1): if n % i == 0: res.append(i) if i != n // i: res.append(n // i) return res @staticmethod def round_up(a, b): return -(-a // b) @staticmethod def is_prime(n): if n < 2: return False if n == 2: return True if n % 2 == 0: return False d = int(n ** 0.5) + 1 for i in range(3, d + 1, 2): if n % i == 0: return False return True def pop_count(x): x = x - ((x >> 1) & 0x5555555555555555) x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333) x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f x = x + (x >> 8) x = x + (x >> 16) x = x + (x >> 32) return x & 0x0000007f MOD = int(1e09) + 7 INF = int(1e15) def pm(X): res = {} for i in range(2, int(X ** 0.5) + 1): if X % i == 0: res[i] = 0 while X % i == 0: X //= i res[i] += 1 if X > 1: res[X] = 1 return res def solve(): N = Scanner.int() # N!の素因数分解 M = defaultdict(int) for i in range(2, N + 1): tmp = i for j in range(2, int(i ** 0.5) + 1): while tmp % j == 0: M[j] += 1 tmp //= j if tmp > 1: M[tmp] += 1 ans = 0 # 75 for p in range(2, N+1): if M[p] >= 74: ans += 1 # 3 * 25 # 5 * 25 for p in range(2, N + 1): for q in range(2, N+1): if p == q: continue if M[p] >= 2 and M[q] >= 24: ans += 1 if M[p] >= 4 and M[q] >= 14: ans += 1 # 5 * 5 * 3 for p in range(2, N+1): for q in range(p + 1, N + 1): for r in range(2, N + 1): if p == r: continue if q == r: continue if M[p] >= 4 and M[q] >= 4 and M[r] >= 2: ans += 1 print(ans) def main(): # sys.stdin = open("sample.txt") solve() if __name__ == "__main__": main()
p03213
n = int(eval(input())) primes = [2] for i in range(3, 100): flag = True for j in primes: if i%j==0: flag = False break if flag: primes.append(i) factors = [0 for i in range(len(primes))] def mul(x): if x==2: factors[0] += 1 return 2 else: tmp = x while tmp != 1: for i, prime in enumerate(primes): if tmp%prime==0: factors[i] += 1 tmp = tmp//prime break return x*mul(x-1) mul(n) num74 = 0 num24 = 0 num14 = 0 num4 = 0 num2 = 0 for factor in factors: if factor>=74: num74 += 1 elif factor>=24: num24 += 1 elif factor>=14: num14 += 1 elif factor>=4: num4 += 1 elif factor >=2: num2 += 1 ans = 0 ''' 3 * 5 * 5 ''' tmp1 = num74+num24+num14+num4 tmp2 = num2 ans += tmp1*(tmp1-1)//2*tmp2 + tmp1*(tmp1-1)//2*(tmp1-2) ''' 5 * 15 ''' tmp1 = num74+num24+num14 tmp2 = num4 ans += tmp1*tmp2 + tmp1*(tmp1-1) ''' 3 * 25 ''' tmp1 = num74+num24 tmp2 = num14+num4+num2 ans += tmp1*tmp2 + tmp1*(tmp1-1) ''' 75 ''' tmp1 = num74 ans += tmp1 print(ans)
n = int(eval(input())) primes = [2] for i in range(3, 100): flag = True for j in primes: if i%j==0: flag = False break if flag: primes.append(i) factors = [0 for i in range(len(primes))] def mul(x): #if x==2: # factors[0] += 1 # return 2 if x==1: return 1 else: tmp = x while tmp != 1: for i, prime in enumerate(primes): if tmp%prime==0: factors[i] += 1 tmp = tmp//prime break return x*mul(x-1) mul(n) num74 = 0 num24 = 0 num14 = 0 num4 = 0 num2 = 0 for factor in factors: if factor>=74: num74 += 1 elif factor>=24: num24 += 1 elif factor>=14: num14 += 1 elif factor>=4: num4 += 1 elif factor >=2: num2 += 1 ans = 0 ''' 3 * 5 * 5 ''' tmp1 = num74+num24+num14+num4 tmp2 = num2 ans += tmp1*(tmp1-1)//2*tmp2 + tmp1*(tmp1-1)//2*(tmp1-2) ''' 5 * 15 ''' tmp1 = num74+num24+num14 tmp2 = num4 ans += tmp1*tmp2 + tmp1*(tmp1-1) ''' 3 * 25 ''' tmp1 = num74+num24 tmp2 = num14+num4+num2 ans += tmp1*tmp2 + tmp1*(tmp1-1) ''' 75 ''' tmp1 = num74 ans += tmp1 print(ans)
p03213
# エラトステネスの篩 def make_prime_table(N): sieve = list(range(N + 1)) sieve[0] = -1 sieve[1] = -1 for i in range(2, int(N ** 0.5) + 1): if sieve[i] != i: continue for j in range(i * i, N + 1, i): if sieve[j] == j: sieve[j] = i return sieve N = int(eval(input())) prime_table = make_prime_table(100) d = {} for i in range(2, N + 1): while i != 1: d.setdefault(prime_table[i], 0) d[prime_table[i]] += 1 i //= prime_table[i] # 75 = 5 * 5 * 3 # = 15 * 5 # = 25 * 3 # = 75 n74 = 0 n24 = 0 n14 = 0 n4 = 0 n2 = 0 for k in d: if d[k] >= 74: n74 += 1 if d[k] >= 24: n24 += 1 if d[k] >= 14: n14 += 1 if d[k] >= 4: n4 += 1 if d[k] >= 2: n2 += 1 result = 0 # x ^ 4 * y ^ 4 * z ^ 2 の約数の個数は75個 result += n4 * (n4 - 1) // 2 * (n2 - 2) # x ^ 14 * y ^ 4 の約数の個数は75個 result += n14 * (n4 - 1) # x ^ 24 * y ^ 2 の約数の個数は75個 result += n24 * (n2 - 1) # x ^ 74 の約数の個数は75個 result += n74 print(result)
# エラトステネスの篩 def make_prime_table(n): sieve = list(range(n + 1)) sieve[0] = -1 sieve[1] = -1 for i in range(2, int(n ** 0.5) + 1): if sieve[i] != i: continue for j in range(i * i, n + 1, i): if sieve[j] == j: sieve[j] = i return sieve def prime_factorize(n): result = [] while n != 1: p = prime_table[n] c = 0 while n % p == 0: n //= p c += 1 result.append((p, c)) return result N = int(eval(input())) prime_table = make_prime_table(100) d = {} for i in range(2, N + 1): for p, c in prime_factorize(i): d.setdefault(p, 0) d[p] += c # 75 = 5 * 5 * 3 # = 15 * 5 # = 25 * 3 # = 75 n74 = 0 n24 = 0 n14 = 0 n4 = 0 n2 = 0 for k in d: if d[k] >= 74: n74 += 1 if d[k] >= 24: n24 += 1 if d[k] >= 14: n14 += 1 if d[k] >= 4: n4 += 1 if d[k] >= 2: n2 += 1 result = 0 # x ^ 4 * y ^ 4 * z ^ 2 の約数の個数は75個 result += n4 * (n4 - 1) // 2 * (n2 - 2) # x ^ 14 * y ^ 4 の約数の個数は75個 result += n14 * (n4 - 1) # x ^ 24 * y ^ 2 の約数の個数は75個 result += n24 * (n2 - 1) # x ^ 74 の約数の個数は75個 result += n74 print(result)
p03213
# エラトステネスの篩 def make_prime_table(n): sieve = list(range(n + 1)) sieve[0] = -1 sieve[1] = -1 for i in range(2, int(n ** 0.5) + 1): if sieve[i] != i: continue for j in range(i * i, n + 1, i): if sieve[j] == j: sieve[j] = i return sieve def prime_factorize(n): result = [] while n != 1: p = prime_table[n] c = 0 while n % p == 0: n //= p c += 1 result.append((p, c)) return result N = int(eval(input())) prime_table = make_prime_table(N) d = {} for i in range(2, N + 1): for p, c in prime_factorize(i): d.setdefault(p, 0) d[p] += c # 75 = 5 * 5 * 3 # = 15 * 5 # = 25 * 3 # = 75 n74 = 0 n24 = 0 n14 = 0 n4 = 0 n2 = 0 for k in d: if d[k] >= 74: n74 += 1 if d[k] >= 24: n24 += 1 if d[k] >= 14: n14 += 1 if d[k] >= 4: n4 += 1 if d[k] >= 2: n2 += 1 result = 0 # x ^ 4 * y ^ 4 * z ^ 2 の約数の個数は75個 result += n4 * (n4 - 1) // 2 * (n2 - 2) # x ^ 14 * y ^ 4 の約数の個数は75個 result += n14 * (n4 - 1) # x ^ 24 * y ^ 2 の約数の個数は75個 result += n24 * (n2 - 1) # x ^ 74 の約数の個数は75個 result += n74 print(result)
def make_prime_table(n): sieve = list(range(n + 1)) sieve[0] = -1 sieve[1] = -1 for i in range(4, n + 1, 2): sieve[i] = 2 for i in range(3, int(n ** 0.5) + 1, 2): if sieve[i] != i: continue for j in range(i * i, n + 1, i * 2): if sieve[j] == j: sieve[j] = i return sieve def prime_factorize(n): result = [] while n != 1: p = prime_table[n] e = 0 while n % p == 0: n //= p e += 1 result.append((p, e)) return result N = int(eval(input())) prime_table = make_prime_table(N) d = {} for i in range(2, N + 1): for p, e in prime_factorize(i): d.setdefault(p, 0) d[p] += e # 75 = 5 * 5 * 3 # = 15 * 5 # = 25 * 3 # = 75 n74 = 0 n24 = 0 n14 = 0 n4 = 0 n2 = 0 for k in d: if d[k] >= 74: n74 += 1 if d[k] >= 24: n24 += 1 if d[k] >= 14: n14 += 1 if d[k] >= 4: n4 += 1 if d[k] >= 2: n2 += 1 result = 0 # x ^ 4 * y ^ 4 * z ^ 2 の約数の個数は75個 result += n4 * (n4 - 1) // 2 * (n2 - 2) # x ^ 14 * y ^ 4 の約数の個数は75個 result += n14 * (n4 - 1) # x ^ 24 * y ^ 2 の約数の個数は75個 result += n24 * (n2 - 1) # x ^ 74 の約数の個数は75個 result += n74 print(result)
p03213
def prime_factorize(N,lis): a = [] n = N while n % 2 == 0: lis[2] += 1 n //= 2 f = 3 while f * f <= N: if n % f == 0: lis[f] += 1 n //= f else: f += 2 if n != 1: lis[n] += 1 N = int(eval(input())) lis = [0] * 101 for i in range(1,N+1): prime_factorize(i,lis) #print(lis) lis.sort() ans = 0 for i in range(101): for j in range(i+1,101): for k in range(j+1,101): if lis[i] >= 2 and lis[j] >= 4: ans += 1 if lis[i] >= 4: ans += 2 for i in range(101): for j in range(i+1,101): if lis[i] >= 4 and lis[j] >= 14: ans += 1 if lis[i] >= 14: ans += 1 if lis[i] >= 2 and lis[j] >= 24: ans += 1 if lis[i] >= 24: ans += 1 for i in range(101): if lis[i] >= 74: ans += 1 print(ans)
def prime_factorize(N,lis): a = [] n = N while n % 2 == 0: lis[2] += 1 n //= 2 f = 3 while f * f <= N: if n % f == 0: lis[f] += 1 n //= f else: f += 2 if n != 1: lis[n] += 1 N = int(eval(input())) lis = [0] * 101 for i in range(1,N+1): prime_factorize(i,lis) d = [0] * 100 for i in lis: d[i] += 1 for i in reversed(list(range(len(d)-1))): d[i] += d[i+1] print((d[74] + d[24] * (d[2]-1) + d[14] * (d[4]-1) + (d[4] * (d[4]-1) * (d[2]-2)) // 2))
p03213
import itertools from collections import Counter n = int(eval(input())) # 素因数分解した結果のリスト # {1: [], 2: [2], 3: [3], 4: [2, 2], 5: [5]} divs = {} primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] for i in range(1, n + 1): divs[i] = [] x = i while x >= 2: for p in primes: if x % p == 0: x //= p divs[i].append(p) # flatten fdivs = list(itertools.chain.from_iterable(list(divs.values()))) counts = Counter(fdivs) ans = 0 # 75==5*5*3 # https://juken-mikata.net/how-to/mathematics/number-of-divisor.html # 4, 4, 2 選んだら75数になる ge4 = len([c for c in list(counts.values()) if c >= 4]) ge2 = len([c for c in list(counts.values()) if c >= 2]) ans += ge4 * (ge4 - 1) / 2 * (ge2 - 2) # 75==5*15 # 4, 14 選ぶ ge14 = len([c for c in list(counts.values()) if c >= 14]) ans += ge14 * (ge4 - 1) # 75==25*3 # 24, 2 選ぶ ge24 = len([c for c in list(counts.values()) if c >= 24]) ans += ge24 * (ge2 - 1) # 75 ==75*1 # 74 選ぶ ge74 = len([c for c in list(counts.values()) if c >= 74]) ans += ge74 print((int(ans)))
import itertools import math import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10 ** 9) INF = float("inf") IINF = 10 ** 18 MOD = 10 ** 9 + 7 # MOD = 998244353 def get_factors(n): """ 素因数分解 :param int n: :rtype: list of int """ if n <= 1: return [] ret = [] while n > 2 and n % 2 == 0: ret.append(2) n //= 2 i = 3 while i <= math.sqrt(n): if n % i == 0: ret.append(i) n //= i else: i += 2 ret.append(n) return ret N = int(sys.stdin.buffer.readline()) counts = [0] * 101 for n in range(1, N + 1): for f in get_factors(n): counts[f] += 1 t = [] for c in counts: if c >= 2: t.append(c) counts = t # 素因数の使い方のパターン数が # 3, 25 と 3, 5, 5 と 15, 5 と 75 のとき約数が75個 ans = 0 for i, j, k in itertools.combinations(list(range(len(counts))), r=3): if counts[i] >= 2 and counts[j] >= 4 and counts[k] >= 4: ans += 1 if counts[i] >= 4 and counts[j] >= 2 and counts[k] >= 4: ans += 1 if counts[i] >= 4 and counts[j] >= 4 and counts[k] >= 2: ans += 1 for i, j in itertools.combinations(list(range(len(counts))), r=2): if counts[i] >= 2 and counts[j] >= 24: ans += 1 if counts[i] >= 24 and counts[j] >= 2: ans += 1 if counts[i] >= 4 and counts[j] >= 14: ans += 1 if counts[i] >= 14 and counts[j] >= 4: ans += 1 for c in counts: if c >= 74: ans += 1 print(ans)
p03213
from collections import Counter, defaultdict N = int(eval(input())) # 素数のリスト def createPrimeList(N, isTable=True): isPrime = [True] * N isPrime[0] = False isPrime[1] = False for i in range(2, N): if not isPrime[i]: continue for p in range(i * 2, N, i): isPrime[p] = False return isPrime if isTable else [i for i in range(2, N) if isPrime[i]] # 素因数分解(複数回) isPrime = createPrimeList(10**5, False) def primeFactorization(N): primes = Counter() for p in isPrime: while N % p == 0: N //= p primes[p] += 1 return primes primes = Counter() for i in range(1, N + 1): primes += primeFactorization(i) cnt = defaultdict(int) for c in list(primes.values()): c += 1 for d in (3, 5, 15, 25, 75): if c >= d: cnt[d] += 1 ans = 0 ans += cnt[5] * (cnt[5] - 1) * (cnt[3] - 2) // 2 ans += cnt[25] * (cnt[3] - 1) ans += cnt[15] * (cnt[5] - 1) ans += cnt[75] print(ans)
from collections import Counter, defaultdict N = int(eval(input())) def primeFactorization(N): primes = Counter() R = int(N**(0.5)) + 1 for num in range(2, R): while N % num == 0: N //= num primes[num] += 1 if N > 1 : primes[N] = 1 return primes primes = Counter() for i in range(1, N + 1): primes += primeFactorization(i) cnt = defaultdict(int) for c in list(primes.values()): c += 1 for d in (3, 5, 15, 25, 75): if c >= d: cnt[d] += 1 ans = 0 ans += cnt[5] * (cnt[5] - 1) * (cnt[3] - 2) // 2 ans += cnt[25] * (cnt[3] - 1) ans += cnt[15] * (cnt[5] - 1) ans += cnt[75] print(ans)
p03213
from collections import Counter, defaultdict N = int(eval(input())) def primeFactorization(N): primes = Counter() R = int(N**(0.5)) + 1 for num in range(2, R): while N % num == 0: N //= num primes[num] += 1 if N > 1 : primes[N] = 1 return primes primes = Counter() for i in range(1, N + 1): primes += primeFactorization(i) cnt = defaultdict(int) for c in list(primes.values()): c += 1 for d in (3, 5, 15, 25, 75): if c >= d: cnt[d] += 1 ans = 0 ans += cnt[5] * (cnt[5] - 1) * (cnt[3] - 2) // 2 ans += cnt[25] * (cnt[3] - 1) ans += cnt[15] * (cnt[5] - 1) ans += cnt[75] print(ans)
from collections import Counter, defaultdict N = int(eval(input())) # 素数のリスト def createPrimeList(N, isTable=True): isPrime = [True] * (N + 1) isPrime[0] = False isPrime[1] = False for i in range(2, N): if not isPrime[i]: continue for p in range(i * 2, N, i): isPrime[p] = False return isPrime if isTable else [i for i in range(2, N) if isPrime[i]] # 素因数分解(複数回) primeList = createPrimeList(100, False) def primeFactorization(N): primes = Counter() for p in primeList: while N % p == 0: N //= p primes[p] += 1 return primes primes = Counter() for i in range(1, N + 1): primes += primeFactorization(i) cnt = defaultdict(int) for c in list(primes.values()): c += 1 for d in (3, 5, 15, 25, 75): if c >= d: cnt[d] += 1 ans = 0 ans += cnt[5] * (cnt[5] - 1) * (cnt[3] - 2) // 2 ans += cnt[25] * (cnt[3] - 1) ans += cnt[15] * (cnt[5] - 1) ans += cnt[75] print(ans)
p03213
N = int(eval(input())) from math import ceil, sqrt, factorial from itertools import permutations def eratosthenes(n): l = [1 for i in range(n+1)] l[0] = l[1] = 0 for i in range(2, ceil(sqrt(n))): if l[i] == 0: continue for j in range(i*2, n+1, i): l[j] = 0 return l m = factorial(N) ans = set() p = eratosthenes(530) p = [i for i,v in enumerate(p) if v ] for i in p: a = i**74 if not m % a: ans.add(a) break for a,b in permutations(p,2): c = a**2*b**24 if not m % c: ans.add(c) c = a**4*b**14 if not m % c: ans.add(c) for a,b,c in permutations(p, 3): d = a**2 * b**4 * c ** 4 if not m % d: ans.add(d) print((len(ans)))
N = int(eval(input())) p = [0] * (N+1) def is_prime(n): for i in range(2, n): if not n % i: return False return True def n(m): return sum([True for i in p if i >= m]) l = [i for i in range(2, N+1) if is_prime(i)] for i in range(2, N+1): for j in l: while not i % j: p[j] += 1 i //= j print((n(74) + (n(2)-1) * n(24) + (n(2)-2) * ((n(4)-1) * n(4))//2 + (n(4)-1) * n(14)))
p03213
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor INF = float('inf') def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LIM(): return list([int(x) - 1 for x in sys.stdin.readline().split()]) def LS(): return sys.stdin.readline().split() def S(): return sys.stdin.readline().strip() def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def LIRM(n): return [LIM() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] mod = 1000000007 q = I() def sieve(r): not_prime = [0] * r not_prime[0] = 1 not_prime[1] = 1 for i in range(2, r): if not_prime[i] == 0: for j in range(i*2, r, i): not_prime[j] = 1 return [k for k in range(r) if not not_prime[k]] primes = sieve(100) n = len(primes) multiple_cnt = [0] * n for m in range(len(primes)): ret = q p = primes[m] while ret: ret //= p multiple_cnt[m] += ret multiple_cnt.sort() ans = 0 ans += (n - bisect_left(multiple_cnt, 74)) ans += (n - bisect_left(multiple_cnt, 24)) * (n - bisect_left(multiple_cnt, 2) - 1) ans += (n - bisect_left(multiple_cnt, 14)) * (n - bisect_left(multiple_cnt, 4) - 1) ans += (n - bisect_left(multiple_cnt, 4)) * (n - bisect_left(multiple_cnt, 4) - 1) // 2 * (n - bisect_left(multiple_cnt, 2) - 2) print(ans)
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor from operator import mul from functools import reduce sys.setrecursionlimit(2147483647) INF = 10 ** 20 def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def I(): return int(sys.stdin.buffer.readline()) def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] mod = 1000000007 def primes(n): is_prime = [1] * (n + 1) is_prime[0] = 0 is_prime[1] = 0 for i in range(2, int(n**0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = 0 return {i for i in range(n + 1) if is_prime[i]} n = I() prime_set = primes(n) prime_cnt = Counter() for p in prime_set: pi = p while pi < n: prime_cnt[p] += n // pi pi *= p prime_cnt = [v for k, v in prime_cnt.most_common()][::-1] m = len(prime_cnt) print((m - bisect_left(prime_cnt, 74) + (m - bisect_left(prime_cnt, 24)) * (m - bisect_left(prime_cnt, 2) - 1) + (m - bisect_left(prime_cnt, 14)) * (m - bisect_left(prime_cnt, 4) - 1) + (m - bisect_left(prime_cnt, 4)) * ((m - bisect_left(prime_cnt, 4)) - 1) // 2 * ((m - bisect_left(prime_cnt, 2)) - 2)))
p03213
import math dic = {} N = int(eval(input())) for i in range(2, N+1): fact = [] while i % 2 == 0: fact.append(2) i //= 2 f = 3 while f*f <= i: if i%f == 0: fact.append(f) i //= f else: f += 2 if i != 1: fact.append(i) for j in fact: if j in dic: dic[j] += 1 else: dic[j] = 1 cnt = 0 s1 = len([k for k, v in list(dic.items()) if v >= 2]) s2 = len([k for k, v in list(dic.items()) if v >= 4]) s3 = len([k for k, v in list(dic.items()) if v >= 14]) s4 = len([k for k, v in list(dic.items()) if v >= 24]) s5 = len([k for k, v in list(dic.items()) if v >= 74]) #3*5*5 if s2 >= 2 and s1 >= 3: cnt += s2*(s2-1)/2*(s1-2) #15*5 if s3 >= 1: cnt += s3*(s2-1) #25*3 if s4 >= 1: cnt += s4*(s1-1) #75 if s5 >= 1: cnt += s5 print((int(cnt)))
N = int(eval(input())) e = [0]*(N+1) for i in range(2, N+1): cur = i for j in range(2, i+1): while cur % j == 0: e[j] += 1 cur //= j def num(m): return len(list([x for x in e if x >= m-1])) print((num(75) + num(25)*(num(3)-1) + num(15)*(num(5)-1) + num(5)*(num(5)-1)*(num(3)-2)//2))
p03213
from copy import deepcopy def mk_array(init_val, *args): args = args[::-1] res = [init_val for _ in range(args[0])] for arg in args[1:]: res = [deepcopy(res) for _ in range(arg)] return res N = int(eval(input())) e = [0 for _ in range(N + 1)] for i in range(2, N + 1): for j in range(2, i + 1): while i % j == 0: e[j] += 1 i //= j counts = list([x for x in e if x > 0]) prim_count = len(counts) counts = [0] + counts # 1-indexed 化 dp = mk_array(0, prim_count + 1, 75 + 1) dp[0][1] = 1 for i in range(1, prim_count + 1): for j in range(1, 75 + 1): for k in range(min(counts[i], 75 // j - 1) + 1): dp[i][j * (k + 1)] += dp[i - 1][j] print((dp[prim_count][75]))
N = int(eval(input())) e = [0 for _ in range(N + 1)] for i in range(2, N + 1): for j in range(2, i + 1): while i % j == 0: e[j] += 1 i //= j def num(m): return len(tuple([x for x in e if x >= m - 1])) ans = 0 ans += num(75) ans += num(25) * (num(3) - 1) ans += num(15) * (num(5) - 1) ans += num(5) * (num(5) - 1) * (num(3) - 2) // 2 print(ans)
p03213
from collections import defaultdict def cand_count(v, d): return len(tuple([x for x in list(d.values()) if x >= v])) n = int(eval(input())) d = defaultdict(int) for i in range(2, n + 1): b = i j = 2 while j * j <= i: while b % j == 0: b //= j d[j] += 1 j += 1 if b > 1: d[b] += 1 # print(i, j, d) # print(d) ans = 0 ans += cand_count(74, d) ans += cand_count(24, d) * (cand_count(2, d) - 1) ans += cand_count(14, d) * (cand_count(4, d) - 1) ans += cand_count(4, d) * (cand_count(4, d) - 1) // 2 * (cand_count(2, d) - 2) print(ans)
def num(v): return len(tuple([x for x in e if x >= v - 1])) n = int(eval(input())) e = [0] * (n + 1) for i in range(2, n + 1): b = i j = 2 while j * j <= i: while b % j == 0: b //= j e[j] += 1 j += 1 if b > 1: e[b] += 1 e = tuple([x for x in e if x > 0]) ans = 0 ans += num(75) ans += num(25) * (num(3) - 1) ans += num(15) * (num(5) - 1) ans += num(5) * (num(5) - 1) // 2 * (num(3) - 2) print(ans)
p03213
from collections import defaultdict def get_yakusuu(num): yakusuu_dic = defaultdict(int) seed_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] for now_num in range(1, num + 1): for num_ele in seed_primes: if now_num < num_ele: break while now_num % num_ele == 0: yakusuu_dic[num_ele] += 1 now_num = now_num // num_ele return list(yakusuu_dic.values()) def calc(yakusuu_dic, lim): count = 0 for num in yakusuu_dic: if num >= lim: count += 1 else: break return count def main(): num = int(eval(input())) yakusuu_dic = get_yakusuu(num) yakusuu_dic.sort(reverse=True) up_4 = calc(yakusuu_dic, 4) up_2 = calc(yakusuu_dic, 2) ans1 = max(up_4 * (up_4 - 1) * (up_2 - 2) // 2, 0) up_24 = calc(yakusuu_dic, 24) ans2 = max(up_24 * (up_2 - 1), 0) up_14 = calc(yakusuu_dic, 14) ans3 = max(up_14 * (up_4 - 1), 0) up_74 = calc(yakusuu_dic, 74) ans4 = up_74 ans = ans1 + ans2 + ans3 + ans4 print(ans) if __name__ == '__main__': main()
def main2(): dic = {1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0, 10:1, 11:1, 12:1, 13:1, 14:2, 15:2, 16:3, 17:3, 18:3, 19:3, 20:8, 21:8, 22:11, 23:11, 24:11, 25:11, 26:14, 27:14, 28:32, 29:32, 30:35, 31:35, 32:35, 33:35, 34:42, 35:42, 36:42, 37:42, 38:49, 39:49, 40:49, 41:49, 42:49, 43:49, 44:75, 45:75, 46:86, 47:86, 48:86, 49:86, 50:86, 51:86, 52:123, 53:123, 54:131, 55:131, 56:131, 57:131, 58:148, 59:148, 60:153, 61:153, 62:170, 63:170, 64:170, 65:170, 66:170, 67:170, 68:227, 69:227, 70:227, 71:227, 72:227, 73:227, 74:250, 75:250, 76:323, 77:323, 78:324, 79:324, 80:324, 81:324, 82:354, 83:354, 84:354, 85:354, 86:384, 87:384, 88:384, 89:384, 90:384, 91:391, 92:491, 93:491, 94:529, 95:529, 96:529, 97:529, 98:529, 99:529, 100:543} print((dic[int(eval(input()))])) if __name__ == '__main__': main2()
p03213
# -*- coding: utf-8 -*- """ 解説参考 ・まず素因数分解で階乗全部バラす ・そこからいい感じの組み合わせを探して数える """ N = int(eval(input())) # 階乗の素因数分解:ひとつずつ分解したものを合算 e = [0] * (N+1) # 階乗の各値ループ for i in range(2, N+1): num = i # 素因数分解するループ for j in range(2, N+1): while num % j == 0: num //= j e[j] += 1 # 約数75(各指数+1をかける)を取りうる素因数の組み合わせを探していく nums = set() # 指数が4, 4, 2 for p in range(2, N+1): for q in range(2, N+1): for r in range(2, N+1): if (e[p] >= 4 and e[q] >= 4 and e[r] >= 2 and p != q and q != r and r != p): nums.add(pow(p, 4) * pow(q, 4) * pow(r, 2)) # 指数が14, 4 or 24, 2 for p in range(2, N+1): for q in range(2, N+1): if e[p] >= 14 and e[q] >= 4 and p != q: nums.add(pow(p, 14) * pow(q, 4)) if e[p] >= 24 and e[q] >= 2 and p != q: nums.add(pow(p, 24) * pow(q, 2)) # 指数が74 for p in range(2, N+1): if e[p] >= 74: nums.add(pow(p, 74)) print((len(nums)))
# -*- coding: utf-8 -*- import sys from collections import Counter def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print('Yes') def No(): print('No') def YES(): print('YES') def NO(): print('NO') sys.setrecursionlimit(10 ** 9) INF = 10 ** 18 MOD = 10 ** 9 + 7 def factorize(num: int) -> dict: """ 素因数分解 """ from math import sqrt from collections import Counter d = Counter() # 終点はルート切り捨て+1 for i in range(2, int(sqrt(num))+1): # 素因数分解:小さい方から割れるだけ割って素数をカウント while num % i == 0: num //= i d[i] += 1 # 1まで分解したら終了 if num == 1: break # 最後に残ったnumは素数(ただし1^1は1^0なので数に入れない) if num != 1: d[num] += 1 return d N = INT() # N!までを全部素数冪でまとめる primes = Counter() for i in range(2, N+1): primes.update(factorize(i)) # 約数が75になる素数冪の組み合わせを数える primes = sorted(primes.values()) M = len(primes) cnt = 0 # 3種類使う for i, v1 in enumerate(primes): for j, v2 in enumerate(primes[i+1:], i+1): for k, v3 in enumerate(primes[j+1:], j+1): if v1 >= 2 and v2 >= 4 and v3 >= 4: cnt += 1 if v1 >= 4 and v2 >= 2 and v3 >= 4: cnt += 1 if v1 >= 4 and v2 >= 4 and v3 >= 2: cnt += 1 # 2種類使う for i, v1 in enumerate(primes): for j, v2 in enumerate(primes[i+1:], i+1): if v1 >= 2 and v2 >= 24: cnt += 1 if v1 >= 4 and v2 >= 14: cnt += 1 if v1 >= 24 and v2 >= 2: cnt += 1 if v1 >= 14 and v2 >= 4: cnt += 1 # 1種類使う for i, v1 in enumerate(primes): if v1 >= 74: cnt += 1 print(cnt)
p03213
N = int(eval(input())) lim = 1 for i in range(N): lim *= (i+1) Prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47,\ 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] Ans = 0 for i in range(23): for j in range(i+1, 24): for k in range(j+1, 25): a, b, c = Prime[i], Prime[j], Prime[k] d, e, f = (a**4)*(b**4)*(c**2), (a**4)*(b**2)*(c**4), (a**2)*(b**4)*(c**4) if d <= lim and lim%d == 0: Ans += 1 if e <= lim and lim%e == 0: Ans += 1 if f <= lim and lim%f == 0: Ans += 1 for i in range(24): for j in range(i+1, 25): a, b = Prime[i], Prime[j] d, e, f, g = (a**24)*(b**2), (a**2)*(b**24), (a**4)*(b**14), (a**14)*(b**4) if d <= lim and lim%d == 0: Ans += 1 if e <= lim and lim%e == 0: Ans += 1 if f <= lim and lim%f == 0: Ans += 1 if g <= lim and lim%g == 0: Ans += 1 for i in range(5): if Prime[i] ** 74 <= lim and lim % (Prime[i]**74) == 0: Ans += 1 print(Ans)
import sys from collections import defaultdict def solve(): input = sys.stdin.readline N = int(eval(input())) primes = defaultdict(int) ans = 0 for i in range(1, N + 1): k = i for j in range(2, i+1): if j ** 2 > i: break if k % j == 0: while k % j == 0: primes[j] += 1 k //= j if k > 1: primes[k] += 1 P = [] for key in primes: P.append(primes[key]) pn = len(P) for i in range(pn): if P[i] >= 74: ans += 1 if P[i] >= 24: for j in range(pn): if P[j] >= 2 and j != i: ans += 1 if P[i] >= 14: for j in range(pn): if P[j] >= 4 and j != i: ans += 1 if P[i] >= 4: for j in range(i+1, pn): if P[j] >= 4: for k in range(pn): if P[k] >= 2 and k != i and k != j: ans += 1 print(ans) #print(primes) #print(P) return 0 if __name__ == "__main__": solve()
p03213
P = [1 for _ in range(100)] P[0]=0 P[1]=0 for i in range(2,10): for j in range(i*i,100,i): P[j] = 0 Q = [] for i in range(100): if P[i]==1: Q.append(i) C = {i:0 for i in Q} N = int(eval(input())) for i in range(2,N+1): x = i for p in C: while x%p==0: x = x//p C[p] += 1 #2 4 4 c2 = 0 c4 = 0 for p in C: if 2<=C[p]<4: c2 += 1 elif C[p]>=4: c4 += 1 cnt = c2*((c4*(c4-1))//2)+c4*(((c4-1)*(c4-2))//2) #2 24 c2 = 0 c24 = 0 for p in C: if 2<=C[p]<24: c2 += 1 elif C[p]>=24: c24 += 1 cnt += c2*c24+c24*(c24-1) #4 14 c4 = 0 c14 = 0 for p in C: if 4<=C[p]<14: c4 += 1 elif C[p]>=14: c14 += 1 cnt += c4*c14+c14*(c14-1) #75 c74 = 0 for p in C: if C[p]>=74: c74 += 1 cnt += c74 print(cnt)
P = [1 for _ in range(100)] P[0]=0 P[1]=0 for i in range(2,11): for j in range(i*i,100,i): P[j] = 0 Q = [] for i in range(100): if P[i]==1: Q.append(i) N = int(eval(input())) C = {p:0 for p in Q} for p in Q: cnt = 0 k = 1 while p**k<=N: for i in range(2,N+1): if i%(p**k)==0: cnt += 1 k += 1 C[p]=cnt c2=0 c4=0 c14=0 c24=0 c74=0 for p in C: if C[p]>=2: c2 += 1 if C[p]>=4: c4 += 1 if C[p]>=14: c14 += 1 if C[p]>=24: c24 += 1 if C[p]>=74: c74 += 1 ans = ((c4*(c4-1))//2)*(c2-2) ans += c24*(c2-1) ans += c14*(c4-1) ans += c74 print(ans)
p03213
P = [1 for _ in range(100)] P[0]=0 P[1]=0 for i in range(2,11): for j in range(i*i,100,i): P[j] = 0 Q = [] for i in range(2,100): if P[i]==1: Q.append(i) C = {q:0 for q in Q} N = int(eval(input())) for i in range(2,N+1): x = i for q in Q: while x%q==0: x = x//q C[q] += 1 D = {2:0,4:0,14:0,24:0,74:0} for q in Q: if C[q]>=2: D[2] += 1 if C[q]>=4: D[4] += 1 if C[q]>=14: D[14] += 1 if C[q]>=24: D[24] += 1 if C[q]>=74: D[74] += 1 cnt = D[74] cnt += (D[2]-D[24])*D[24]+(D[24]*(D[24]-1)) cnt += (D[4]-D[14])*D[14]+(D[14]*(D[14]-1)) cnt += (D[2]-D[4])*(D[4]*(D[4]-1))//2+(D[4]*(D[4]-1)*(D[4]-2))//2 print(cnt)
P = [1 for _ in range(100)] P[0]=0 P[1]=0 for i in range(2,11): for j in range(i**2,100,i): P[j] = 0 Q = [] for i in range(100): if P[i]==1: Q.append(i) N = int(eval(input())) C = {p:0 for p in Q} for i in range(2,N+1): for p in Q: if i%p==0: x = i while x%p==0: x = x//p C[p] += 1 cnt = 0 for p in Q: if C[p]>=74: cnt += 1 cnt1 = 0 cnt2 = 0 for p in Q: if C[p]>=24: cnt2 += 1 elif C[p]>=2: cnt1 += 1 cnt += cnt2*(cnt2-1)+cnt2*cnt1 cnt1 = 0 cnt2 = 0 for p in Q: if C[p]>=14: cnt2 += 1 elif C[p]>=4: cnt1 += 1 cnt += cnt2*(cnt2-1)+cnt2*cnt1 cnt1 = 0 cnt2 = 0 for p in Q: if C[p]>=4: cnt2 += 1 elif C[p]>=2: cnt1 += 1 cnt += (cnt2*(cnt2-1)*(cnt2-2))//2+((cnt2*(cnt2-1))//2)*cnt1 print(cnt)
p03213
from collections import Counter as c from itertools import permutations as p def fact(n): d=[] for i in range(2,int(n**0.5)+2): while n%i==0: n//=i d.append(i) if n!=1:d.append(n) return c(d) n=int(eval(input())) d=c() for i in range(1,n+1): d+=fact(i) f=lambda n,x:sum(1 for i in p(list(d.values()),n) if all(map(lambda x,y:x>=y,i,x))) print((f(3,(2,4,4))//2+f(2,(2,24))+f(2,(4,14))+f(1,(74,))))
from collections import defaultdict as dd from itertools import permutations as p def factorize(n): d = dd(int) for i in range(2, int(n**0.5)+1): while n%i==0: d[i] += 1 n //= i if not n: break if n>1: d[n] += 1 return d N = int(eval(input())) d = dd(int) for i in range(1, N+1): e = factorize(i) for i,j in list(e.items()): d[i] += j ans = 0 for i, j, k in p(list(d.values()), 3): if i>=2 and j>=4 and k>=4: ans += 1 ans //= 2 for i, j in p(list(d.values()), 2): if i>=2 and j>=24: ans += 1 if i>=4 and j>=14: ans += 1 for i in list(d.values()): if i>=74: ans += 1 print(ans)
p03213
from collections import defaultdict as dd from itertools import permutations as p def factorize(n): d = dd(int) for i in range(2, int(n**0.5)+1): while n%i==0: d[i] += 1 n //= i if not n: break if n>1: d[n] += 1 return d N = int(eval(input())) d = dd(int) for i in range(1, N+1): e = factorize(i) for i,j in list(e.items()): d[i] += j ans = 0 for i, j, k in p(list(d.values()), 3): if i>=2 and j>=4 and k>=4: ans += 1 ans //= 2 for i, j in p(list(d.values()), 2): if i>=2 and j>=24: ans += 1 if i>=4 and j>=14: ans += 1 for i in list(d.values()): if i>=74: ans += 1 print(ans)
from collections import defaultdict as dd from itertools import permutations as p def factorize(n): d = dd(int) for i in range(2, int(n**0.5)+1): while n%i==0: d[i] += 1 n //= i if not n: break if n>1: d[n] += 1 return d N = int(eval(input())) d = dd(int) for i in range(1, N+1): e = factorize(i) for i,j in list(e.items()): d[i] += j vl = list(d.values()) ans = sum(1 for i, j, k in p(vl, 3) if i>=2 and j>=4 and k>=4)//2 ans += sum(1 for i, j in p(vl, 2) if i>=2 and j>=24) ans += sum(1 for i, j in p(vl, 2) if i>=4 and j>=14) ans += sum(1 for i in vl if i>=74) print(ans)
p03213
N = int(eval(input())) prime_number = [2, 3, 5, 7] prim = [2, 3, 5, 7] #素数作成 for i in range(2, 101): prime_flag = True for j in prim: if i % j == 0: prime_flag = False break if prime_flag: prime_number.append(i) prime_factor = [0] * len(prime_number) for i in range(2, N + 1): tmp = i for j in range(len(prime_number)): while tmp % prime_number[j] == 0: prime_factor[j] += 1 tmp //= prime_number[j] count2 = 0 count4 = 0 count14 = 0 count24 = 0 count74 = 0 for i in prime_factor: if i >= 2: count2 += 1 if i >= 4: count4 += 1 if i >= 14: count14 += 1 if i >= 24: count24 += 1 if i >= 74: count74 += 1 if count4 >= 2: combination4 = count4 * (count4 - 1) // 2 else: combination4 = 0 ans = combination4 * (count2 - 2) + count14 * (count4 - 1) + count24 * (count2 - 1) + count74 print(ans)
ans = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 8, 8, 11, 11, 11, 11, 14, 14, 32, 32, 35, 35, 35, 35, 42, 42, 42, 42, 49, 49, 49, 49, 49, 49, 75, 75, 86, 86, 86, 86, 86, 86, 123, 123, 131, 131, 131, 131, 148, 148, 153, 153, 170, 170, 170, 170, 170, 170, 227, 227, 227, 227, 227, 227, 250, 250, 323, 323, 324, 324, 324, 324, 354, 354, 354, 354, 384, 384, 384, 384, 384, 391, 491, 491, 529, 529, 529, 529, 529, 529, 543] print((ans[int(eval(input()))]))
p03213
# M = a ** x * b ** y * c ** z # の約数の個数は(x + 1)*(y + 1)*(z + 1) # なので約数が75個になるには、以下パターンが考えられる # 75 # 25 * 3 # 15 * 5 # 5 * 5 * 3 # よって1~Nまで素因数分解して、各素因数の指数部分の値を求めて # 計算する import itertools def main(): N = int(eval(input())) d = [0] * (N+1) for i in range(2,N+1): cur = i for j in range(2, i+1): while cur % j == 0: d[j] += 1 cur = cur // j ans = 0 for i in d: if i >= 74: ans += 1 for (x, y, z) in itertools.combinations(d,3): for a, b, c in [[4, 4, 2],[4, 2, 4],[2, 4, 4]]: if x >= a and y >= b and z >= c: ans += 1 for (x, y) in itertools.combinations(d,2): for a, b in [[24,2],[14,4],[4,14],[2,24]]: if x >= a and y >= b: ans += 1 print(ans) main()
from collections import defaultdict def main(): # 75 * 1 # 25 * 3 # 15 * 5 # 5 * 5 * 3 N = int(eval(input())) d = defaultdict(int) for n in range(1, N+1): for i in range(2, int(n ** 0.5) + 1): while n % i == 0: d[i] += 1 n = n // i if n != 1: d[n] += 1 d2 = 0 d4 = 0 d14 = 0 d24 = 0 d74 = 0 for i in list(d.values()): if i >= 2: d2 += 1 if i >= 4: d4 += 1 if i >= 14: d14 += 1 if i >= 24: d24 += 1 if i >= 74: d74 += 1 ans = d74 ans += d24 * (d2 - 1) ans += d14 * (d4 - 1) ans += (d4 * (d4 - 1) * (d2 - 2)) // 2 print(ans) if __name__ == "__main__": main()
p03213
from collections import defaultdict def main(): # 75 * 1 # 25 * 3 # 15 * 5 # 5 * 5 * 3 N = int(eval(input())) d = defaultdict(int) for n in range(1, N+1): for i in range(2, int(n ** 0.5) + 1): while n % i == 0: d[i] += 1 n = n // i if n != 1: d[n] += 1 d2 = 0 d4 = 0 d14 = 0 d24 = 0 d74 = 0 for i in list(d.values()): if i >= 2: d2 += 1 if i >= 4: d4 += 1 if i >= 14: d14 += 1 if i >= 24: d24 += 1 if i >= 74: d74 += 1 ans = d74 ans += d24 * (d2 - 1) ans += d14 * (d4 - 1) ans += (d4 * (d4 - 1) * (d2 - 2)) // 2 print(ans) if __name__ == "__main__": main()
from collections import defaultdict def prime_factor(n): ass = [] for i in range(2,int(n**0.5)+1): while n % i==0: ass.append(i) n = n//i if n != 1: ass.append(n) return ass def main(): N = int(eval(input())) d = defaultdict(int) for i in range(1,N+1): for j in prime_factor(i): d[j] += 1 # 1 * 75 # 3 * 25 # 5 * 15 # 3 * 5 * 5 e = defaultdict(int) for i, j in list(d.items()): if j >= 2: e[2] += 1 if j >= 4: e[4] += 1 if j >= 14: e[14] += 1 if j >= 24: e[24] += 1 if j >= 74: e[74] += 1 ans = 0 ans += (e[2] - 1) * e[24] ans += (e[4] - 1) * e[14] ans += e[74] ans += (e[2] - 2) * e[4] * (e[4] - 1) // 2 print(ans) if __name__ == "__main__": main()
p03213
N = 101 prime = [True]*(N+1) count = [0]*(N+1) prime[0] = prime[1] = False for i in range(N+1): if prime[i]: for j in range(2*i, N+1, i): prime[j] = False a = int(eval(input())) for i in range(1,a+1): cur = i for j in range(2,i+1): if prime[j]: while cur%j==0: count[j]+=1 cur//=j s=r=0 for i in range(1,a+1): if count[i]>=4: s+=1 r+=1 elif count[i]>=2:r+=1 def num(m): # e の要素のうち m-1 以上のものの個数 return len(list([x for x in count if x >= m-1])) #if s>=2and r-2>=1:print(combinations_count(s,2)*(r-2)) #else:print(0) print((num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+num(5)*(num(5)-1)*(num(3)-2)//2))
N = int(eval(input())) e = [0] * (N+1) for i in range(2, N+1): cur = i for j in range(2, i+1): while cur % j == 0: e[j] += 1 cur //= j def num(m): # e の要素のうち m-1 以上のものの個数 return len(list([x for x in e if x >= m-1])) print((num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1)+ num(5) * (num(5) - 1) * (num(3) - 2) // 2))
p03213
n = int(eval(input())) def primes(m) : ps = [2] for i in range(3, m) : for p in ps : if i%p == 0 : break else : ps.append(i) return ps def fdivisor(m) : ps = primes(m) df = {p:0 for p in ps} for i in range(1, m+1) : ii = i while ii != 1 : for p in ps : if ii%p == 0 : df[p] += 1 ii //= p return df ans = 0 df = fdivisor(n) over2 = len([v for v in list(df.values()) if v >= 2]) over4 = len([v for v in list(df.values()) if v >= 4]) over14 = len([v for v in list(df.values()) if v >= 14]) over24 = len([v for v in list(df.values()) if v >= 24]) over74 = len([v for v in list(df.values()) if v >= 74]) ans += over4*(over4-1)//2*(over2-2) ans += over14*(over4-1) ans += over24*(over2-1) ans += over74 print(ans)
n = int(eval(input())) def primes(m) : ps = [2] for i in range(3, m+1) : for p in ps : if i%p == 0 : break else : ps.append(i) return ps def fdivisor(m) : ps = primes(m) df = {p:0 for p in ps} for i in range(1, m+1) : ii = i while ii != 1 : for p in ps : if ii%p == 0 : df[p] += 1 ii //= p return df ans = 0 df = fdivisor(n) over2 = len([v for v in list(df.values()) if v >= 2]) over4 = len([v for v in list(df.values()) if v >= 4]) over14 = len([v for v in list(df.values()) if v >= 14]) over24 = len([v for v in list(df.values()) if v >= 24]) over74 = len([v for v in list(df.values()) if v >= 74]) ans += over4*(over4-1)//2*(over2-2) ans += over14*(over4-1) ans += over24*(over2-1) ans += over74 print(ans)
p03213
from operator import mul from functools import reduce nCr = {} def cmb(n, r): if r == 0 or r == n: return 1 if r == 1: return n if (n,r) in nCr: return nCr[(n,r)] nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1) return nCr[(n,r)] a = int(eval(input())) b = [0 for i in range(15)] j = 0 c = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47] d = [0 for i in range(101)] p = 0 pp = 0 g = 0 gg = 0 ggg = 0 co = 0 for i in range(1,101): k = i while True: if k % c[j] == 0 and k >= c[j]: b[j] += 1 k //= c[j] else: j += 1 if j == 15: j = 0 break for k in range(15): if b[k] >= 74: g += 1 if b[k] >= 24: gg += 1 if b[k] >= 14: ggg += 1 if b[k] >= 4: p += 1 if b[k] >= 2: pp += 1 if i >= 10: d[i] = cmb(p, 2)*cmb((pp-2), 1) + cmb(g, 1) + cmb(gg, 1)*cmb((pp-1), 1) + cmb(ggg, 1)*cmb((p-1), 1) p = 0 pp = 0 g = 0 gg = 0 ggg = 0 print((d[a]))
def cmb(n, r): if n - r < r: r = n - r if n <= 0: return 0 if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2,r+1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p; for k in range(p-1,r,p): numerator[k - offset] //= pivot denominator[k] //= pivot result = 1 for k in range(r): if numerator[k] > 1: result *= int(numerator[k]) return result a = int(eval(input())) b = [0 for i in range(15)] j = 0 c = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47] d = [0 for i in range(101)] p = 0 pp = 0 g = 0 gg = 0 ggg = 0 co = 0 for i in range(1,101): k = i while True: if k % c[j] == 0 and k >= c[j]: b[j] += 1 k //= c[j] else: j += 1 if j == 15: j = 0 break for k in range(15): if b[k] >= 74: g += 1 if b[k] >= 24: gg += 1 if b[k] >= 14: ggg += 1 if b[k] >= 4: p += 1 if b[k] >= 2: pp += 1 if i >= 10: d[i] = cmb(p, 2)*cmb((pp-2), 1) + cmb(g, 1) + cmb(gg, 1)*cmb((pp-1), 1) + cmb(ggg, 1)*cmb((p-1), 1) p = 0 pp = 0 g = 0 gg = 0 ggg = 0 print((d[a]))
p03213
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 N=int(eval(input())) from collections import defaultdict dic=defaultdict(int) for i in range(1,N+1): arr=factorization(i) for a in arr: dic[a[0]]+=a[1] # これら素因数の集まりに対して、 # 2,4,4 # 74 # 2,24 # 4,14 # 個選択できるペアをいくつ作れるかを数える items=list(dic.items()) def c(items,p): return len(list([x for x in items if x[1]>=p])) ans=0 ans+=c(items,74) ans+=(c(items,4)*(c(items,4)-1)*(c(items,2)-2))//2 ans+=c(items,24)*(c(items,2)-1) ans+=c(items,14)*(c(items,4)-1) print(ans)
# 約数の数 = 素因数分解して、各素因数の(指数 + 1)をかけ合わせたもの # 例:12 = 2^2 * 3^1 -> 3 * 2 = 6 (1,2,3,4,6,12) # これが75になるためには、以下のペアを作れる必要がある。この組み合わせを数える # 75 : 指数が74 # 3 * 25 : 指数が2 , 24 # 5 * 15 : 指数が4 , 14 # 3 * 5 * 5 : 指数が2,4,4 import sys readline = sys.stdin.readline N = int(readline()) def factorization(n): res = [] 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 res.append([i,cnt]) if temp != 1: res.append([temp, 1]) if res == []: res.append([n, 1]) return res from collections import defaultdict dic = defaultdict(int) for i in range(1, N + 1): res = factorization(i) for r in res: dic[r[0]] += r[1] ans = 0 vals = list(dic.values()) # 74以上のものを探す i74 = 0 for v in vals: if v >= 74: i74 += 1 ans += i74 i2 = 0 i24 = 0 # 2,24以上のものを探す for v in vals: if v >= 24: i24 += 1 elif v >= 2: i2 += 1 ans += (i24 * (i24 - 1)) ans += i24 * i2 # 5,15以上のものを探す i4 = 0 i14 = 0 for v in vals: if v >= 14: i14 += 1 elif v >= 4: i4 += 1 ans += (i14 * (i14 - 1)) ans += i14 * i4 # 2,4,4を探す i4 = 0 i2 = 0 for v in vals: if v >= 4: i4 += 1 elif v >= 2: i2 += 1 if i4 >= 3: ans += ((i4 * (i4 - 1)) // 2) * (i4 - 2) ans += ((i4 * (i4 - 1)) // 2) * i2 print(ans)
p03213
n = int(eval(input())) e = [0] * (n+1) for i in range(2, n+1): for j in range(2, i+1): while i % j == 0: e[j] += 1 i //= j def count(m): return len(list([x for x in e if x >= m-1])) a = count(75) b = count(25) * (count(3) - 1) c = count(15) * (count(5) - 1) d = count(5) * (count(5) - 1) * (count(3) - 2) // 2 print((a + b + c + d))
n = int(eval(input())) def nprf(m): pf = {} for i in range(2, m + 1): for j in range(2, i + 1): while i % j == 0: pf[j] = pf.get(j, 0) + 1 i //= j return pf def c(P, m): count = 0 for i in P: if P[i] >= m - 1: count += 1 return count P = nprf(n) f75 = c(P, 75) f253 = c(P, 25) * (c(P, 3) - 1) f155 = c(P, 15) * (c(P, 5) - 1) f553 = int(c(P, 5) * (c(P, 5) - 1) * (c(P, 3) - 2) * 0.5) print((f75 + f253 + f155 + f553))
p03213
# 因数を昇順に全列挙 from collections import Counter import math def com(n,r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) fac_list = [] def factoring(n): for i in range(2,n+1): if n % i == 0: fac_list.append(i) n = n // i break if n == 1: return fac_list else: return factoring(n) # (素因数,指数) n = int(eval(input())) c = list(Counter(factoring(math.factorial(n))).values()) # 指数 (2,4,4),(2,24),(4,14),(74) の場合の数 l = [0]*5 # [2,4,14,24,74] for e in c: if e >= 74: index = 4 elif e >= 24: index = 3 elif e >= 14: index = 2 elif e >= 4: index = 1 elif e >= 2: index = 0 else: continue l[index] += 1 sum_l = sum(l) num_74 = l[4] if sum_l - l[0] - 1 > 0: num_4_14 = (l[2] + l[3] + l[4])*(sum_l - l[0] - 1) else: num_4_14 = 0 if sum_l - 1 > 0: num_2_24 = (l[3] + l[4])*(sum_l - 1) else: num_2_24 = 0 if sum_l - l[0] >= 2: num_2_4_4 = com(sum_l-l[0],2)*(sum_l - 2) else: num_2_4_4 = 0 ans = num_74 + num_4_14 + num_2_24 + num_2_4_4 print(ans)
def factoring(n): for i in range(2, n+1): while n % i == 0: n //= i d[i] += 1 N = int(eval(input())) d = [0]*(N+1) for n in range(2,N+1): factoring(n) def num(n): return len([e for e in d if e >= n]) ans = num(74) + num(14)*(num(4)-1) + num(24)*(num(2)-1) + num(4)*(num(4)-1)*(num(2)-2)//2 print(ans)
p03213
d={"o":1,"x":-1} N=int(input()) s=input() s+=s[0] def ans(a): for i in range(1,N+1): a=a+[a[i]*a[i-1]*d[s[i]]] if a[:2]==a[-2:]: return a[:-2] else: return [] for ini in [[1,1],[1,-1],[-1,1],[-1,-1]]: a=ans(ini) if a: print("".join(['S' if x>0 else 'W' for x in a])) break else: print("-1")
d={"o":1,"x":-1} w={"S":1,"W":-1} n={1:"S",-1:"W"} N=int(input()) s=input() s+=s[0] def ans(a): for i in range(1,N+1): a+=n[w[a[i]]*w[a[i-1]]*d[s[i]]] if a[:2]==a[-2:]: return a[:-2] else: return [] for ini in ["SS","SW","WS","WW"]: a=ans(ini) if a: print(a) break else: print("-1")
p03798
a, b = list(map(str, input().split())) c = int(a + b) for i in range(c): if i**2 == c: ans = 'Yes' break else: ans = 'No' print(ans)
a, b = list(map(str, input().split())) c = int(a + b) for i in range(4, 317): if i**2 == c: ans = 'Yes' break else: ans = 'No' print(ans)
p03456
# coding: utf-8 import sys input = sys.stdin.readline N = int(input().replace(" ", "")) print(("Yes" if N**0.5 == int(N**0.5) else "No"))
# coding: utf-8 import sys input = sys.stdin.readline N = int(input().replace(" ", "")) print(("Yes" if (N**0.5).is_integer() else "No"))
p03456
import sys import math A,B=input().split() X=int(A+B) print(('Yes' if math.sqrt(X).is_integer() else 'No'))
import sys A,B=input().split() X=int(A+B) L=[x*x for x in range(1,1001)] if X in L: print('Yes') else: print('No')
p03456