input
stringlengths
20
127k
target
stringlengths
20
119k
problem_id
stringlengths
6
6
a,b = list(map(str,input().split())) x = int(a + b) ans = "No" for i in range(x // 2): if x == i * i: ans = "Yes" print(ans)
a,b = list(map(str,input().split())) x = int(a + b) if x ** 0.5 == int(x ** 0.5): print("Yes") else: print("No")
p03456
a, b = input().split() n = int(a + b) flag = False for i in range(n): if i ** 2 == n: flag = True break print(('Yes' if flag else 'No'))
a, b = input().split() n = int(a + b) flag = False for i in range(1000): if i ** 2 == n: flag = True break print(('Yes' if flag else 'No'))
p03456
a,b = input().split() t = int(a+b) flag = False for i in range(t//2 + 1): if i**2 == t: flag = True break if flag: print("Yes") else: print("No")
a,b = input().split() t = int(a+b) print(("Yes" if t == int(t**0.5)**2 else "No"))
p03456
a,b=input().split() num=int(a+b) for i in range(num): if i*i == num: print('Yes') break else: print('No')
a,b=input().split() x=int(a+b) for i in range(int(x**0.5)+1): if i**2 ==x: print('Yes') exit() print('No')
p03456
a,b = input().split() x = 4 ab = int(a+b) while x*x < ab: x += 1 print(("Yes" if x*x == ab else "No"))
a,b = input().split() ab = int(a+b) x = int(ab**0.5) print(("Yes" if x**2==ab else "No"))
p03456
_in =input().split() #_in = ["10", "21"] #文字の結合 cont_str = _in[0] + _in[1] #数字に変換 cont_num = int(cont_str) #平方数の判定 #総当たり頭悪そう 1<= ab <= 100 なので 4*4~ 100*100 sqrt_flag = False for i in range(4, 1000): sqrt = i * i #print(sqrt) if cont_num == sqrt: sqrt_flag = True break if sqrt_flag: print('Yes') else: print('No')
#入力値の取得 _in =input().split() #_in = ["10", "21"] #文字の結合 cont_str = _in[0] + _in[1] #数字に変換 cont_num = int(cont_str) #平方数の判定 #総当たり頭悪そう 1<= ab <= 100 なので 4*4~ 100*100 sqrt_flag = False for i in range(4, 500): sqrt = i * i #print(sqrt) if cont_num == sqrt: sqrt_flag = True break if sqrt_flag: print('Yes') else: print('No')
p03456
a, b = list(map(int,input().split())) ab = int(str(a) + str(b)) abroot = str(ab**0.5) if abroot.split(".")[1:][0] == "0": print("Yes") else: print("No")
a, b = list(map(int,input().split())) if str(int(str(a) + str(b))**0.5).split(".")[1:][0] == "0": print("Yes") else: print("No")
p03456
from sys import stdin def main() -> None: a = next_int() b = next_int() ab = int(str(a) + str(b)) sqrt = int(ab ** 0.5) print((["No","Yes"][sqrt ** 2 == ab])) def next_int() -> int: return int(next_str()) def next_str() -> str: result = "" while True: tmp = stdin.read(1) if tmp.strip() != "": result += tmp elif tmp != '\r': break return result if __name__ == '__main__': main()
from sys import stdin def main() -> None: a = next_int() b = next_int() ab = int(str(a) + str(b)) sqrt = int(ab ** 0.5) print((["No", "Yes"][int(sqrt ** 2 == ab)])) def next_int() -> int: return int(next_str()) def next_str() -> str: result = "" while True: tmp = stdin.read(1) if tmp.strip() != "": result += tmp elif tmp != '\r': break return result if __name__ == '__main__': main()
p03456
import math a, b = input().split() num = int(a + b) li = [] for i in range(1000): li.append(i ** 2) if (num in li): print('Yes') else: print('No')
import sys import math a, b = input().split() num = int(a + b) rli = [0] for i in range(400): rli.append(i ** 2) if (num in rli): print('Yes') else: print('No')
p03456
a = input().replace(' ','') if int(a)**0.5 % 1 == 0: print('Yes') else: print('No')
a = input().replace(' ','') print(('Yes' if int(a)**0.5 % 1 == 0 else 'No'))
p03456
import math a, b = input().split() n = int(a+b) m = int(math.sqrt(n)) if abs(m**2 - n) < 1e-6: print("Yes") else: print("No")
a, b = input().split() N = int(a+b) if N == int(N**(0.5))**2: print('Yes') else: print('No')
p03456
a, b = input().split() c = int(a + b) print(("Yes" if c ** 0.5 % 1 == 0 else "No"))
a, b = list(map(str, input().split())) c = int(a + b) if c ** 0.5 == int(c ** 0.5): print("Yes") else: print("No")
p03456
a,b=input().split() z=int(a+b) print(("Yes" if z**.5==int(z**.5) else "No"))
print(("No" if int(input().replace(" ",""))**.5%1 else "Yes"))
p03456
a, b = input().split() target = a + b heihousuu = [i ** 2 for i in range(1000) if i ** 2 <= 100100] if int(target) in heihousuu: print('Yes') else: print('No')
a, b = input().split() ab = int(a + b) if (ab ** 0.5).is_integer(): print("Yes") else: print("No")
p03456
import math a,b = input().split() S = a+b K = int(S) if math.sqrt(K) %1 == 0: print("Yes") else: print("No")
import math s,t = input().split() N = int(s+t) if (N**0.5)%1 == 0: print("Yes") else: print("No")
p03456
import math def solve(): a,b = input().split() num = int(a+b) if math.sqrt(num).is_integer(): print('Yes') else: print('No') solve()
def solve(): a,b = input().split() num = int(a+b) for i in range(1,1000): if i**2 == num: print('Yes') return print('No') solve()
p03456
a,b = input().split() ab = a+b for i in range(int(a+b)): if int(a+b) == i**2: print("Yes") exit() print("No")
from math import sqrt a,b = input().split() ab = int(a+b) print((["No","Yes"][int(sqrt(ab))**2 == ab]))
p03456
x = int(input().replace(' ', '')) for i in range(x): if i*i == x: print('Yes') exit() print('No')
x = int(input().replace(' ', '')) print(('Yes' if x in [i*i for i in range(1000)] else 'No'))
p03456
a,b=list(map(str,input().split())) c=int(a+b) sq = [i*i for i in range(1,10001)] if c in sq: print('Yes') else: print('No')
a, b = map(int, input().split()) c = int(str(a) + str(b)) square = [i ** 2 for i in range(1, 500)] print('Yes') if c in square else print('No')
p03456
import math a,b= input().split() gosei = int(a+b) tekito = math.ceil(gosei) r = 'No' for i in range(1,tekito+1): if gosei % i == 0 and i == gosei // i: r = 'Yes' break print(r)
import math a,b= input().split() gosei = int(a+b) tekito = math.ceil(math.sqrt(100100)) r = 'No' for i in range(1,tekito+1): if i**2 == gosei: r = 'Yes' break print(r)
p03456
a,b=input().split() c=a+b c=int(c) if any(i**2 == c for i in range(c//2)): print("Yes") else: print("No")
a,b=input().split() c=a+b c=int(c) if (c ** .5).is_integer(): print("Yes") else: print("No")
p03456
a,b = list(map(str,input().split())) for i in range(1,10001): if i**2 == int(a+b): print('Yes') exit() print('No')
a,b = list(map(str,input().split())) N = int(a+b) import sys for i in range(1,int(N**0.5)+1): if i**2 == N: print('Yes') sys.exit() print('No')
p03456
a, b = list(map(str, input().split())) if int(int(a + b) ** 0.5) == int(a + b) ** 0.5: print("Yes") else: print("No")
a = int("".join(list(input().split()))) if a ** 0.5 == int(a ** 0.5): print("Yes") else: print("No")
p03456
a = list(input().split()) b = int(a[0]+a[1]) if b==int(b**0.5)**2: print("Yes") else: print("No")
a,b = list(input().split()) n = int(a+b) if n==int(n**0.5)**2: print("Yes") else: print("No")
p03456
x = int(input().replace(' ','')) y = int(x**0.5) print(('Yes' if y*y==x else 'No'))
a = int(input().replace(' ','')) s = int(a**0.5) print(('Yes' if s*s == a else 'No'))
p03456
a, b = input().split() x = int(a+b) if str(x ** (0.5))[-1] == "0": print("Yes") else: print("No")
a, b = input().split() x = int(a+b) if str(x**0.5)[-1] == '0': print("Yes") else: print("No")
p03456
a,b=list(map(int,input().split())) for i in range (1,100100): if 1<=b<=9: if 10*a+b==i**2: print('Yes') exit() if 10<=b<=99: if 100*a+b==i**2: print('Yes') exit() if b==100: if 1000*a+b==i**2: print('Yes') exit() print('No')
a,b=input().split() c=a+b for i in range(1,1000): if int(c)==i**2: print('Yes') exit() print('No')
p03456
import math a,b = input().split() print(('Yes' if math.sqrt(int(a+b)) == int(math.sqrt(int(a+b))) else 'No'))
a,b = input().split() n = int(a+b) print(('Yes' if n**0.5 == int(n**0.5) else 'No'))
p03456
import math ab = int(input().replace(' ', '')) r = round(math.sqrt(ab)) print(('Yes' if r**2 == ab else 'No'))
import math ab = int(input().replace(' ', '')) print(('Yes' if math.sqrt(ab).is_integer() else 'No'))
p03456
a, b = input().split() num = int(a + b) ** (1/2) if(num == int(num)): print("Yes") else: print("No")
a, b = input().split() num = int(a + b) ** 0.5 if(num == int(num)): print("Yes") else: print("No")
p03456
a, b = input().split() num = int(a + b) ** 0.5 if(num == int(num)): print("Yes") else: print("No")
a, b = input().split() x = int(a+b)**0.5 ans = "No" if(x == int(x)): ans = "Yes" print(ans)
p03456
a,b = list(map(str,input().split( ))) #print(a+b) count=0 for i in range(1,int(a+b)): if(i*i == int(a+b)): print('Yes') count+=1 break if(count==0):print('No')
print(("No"if int("".join(input().split()))**.5%1 else"Yes"))
p03456
import math A,B = input().split() Num = int(A+B) SqN = math.sqrt(Num) Flag = False for T in range(math.floor(SqN),math.ceil(SqN)+1): if T*T==Num: Flag = True break if Flag: print('Yes') else: print('No')
import math A,B = input().split() Num = int(A+B) SqN = math.sqrt(Num) if math.floor(SqN)**2==Num or math.ceil(SqN)**2==Num: print('Yes') else: print('No')
p03456
def resolve(): import math a, b = input().split() num = int(a+b) ans = (num**0.5)%1 if ans == 0: print('Yes') else: print('No') resolve()
def resolve(): a, b = input().split() num = int(a+b) ans = (num**0.5)%1 if ans == 0: print('Yes') else: print('No') resolve()
p03456
def dist(x,y,x1,y1): return (x-x1)**2+(y-y1)**2 def inWall(x,y,x1,y1,r): return True if dist(x,y,x1,y1) <= (r + 1e-9)**2 else False def isHide(x,y,r,a,b,c): D = abs(a*x+b*y+c)/(a**2+b**2)**0.5 return True if D <= r + 1e-9 else False def isBetween(x,y,tx,ty,sx,sy): a,b,c = dist(x,y,tx,ty),dist(x,y,sx,sy),dist(tx,ty,sx,sy) if c > b and c > a: return True a,b,c = sorted([a,b,c]) return True if c-a-b <= 0 else False while 1: n = eval(input()) if n == 0: break wall = [list(map(int,input().split())) for i in range(n)] for i in range(eval(input())): tx,ty,sx,sy = list(map(int,input().split())) a,b,c = -(ty-sy),tx-sx,sx*ty-sy*tx for x,y,r in wall: t_in,s_in = inWall(x,y,tx,ty,r),inWall(x,y,sx,sy,r) if t_in != s_in or (not t_in and isBetween(x,y,tx,ty,sx,sy) and isHide(x,y,r,a,b,c)): print("Safe") break else: print("Danger")
def inWall(x,y,x1,y1,r): return True if ((x-x1)**2+(y-y1)**2)**0.5 <= r + 1e-9 else False def isHide(x,y,r,a,b,c): D = abs(a*x+b*y+c)/(a**2+b**2)**0.5 return True if D <= r + 1e-9 else False def isBetween(x,y,tx,ty,sx,sy): a,b,c = (x-tx)**2+(y-ty)**2,(x-sx)**2+(y-sy)**2,(sx-tx)**2+(sy-ty)**2 if c > b and c > a: return True a,b,c = sorted([a,b,c]) return True if c-a-b <= 0 else False while 1: n = eval(input()) if n == 0: break wall = [list(map(int,input().split())) for i in range(n)] for i in range(eval(input())): tx,ty,sx,sy = list(map(int,input().split())) a,b,c = -(ty-sy),tx-sx,sx*ty-sy*tx for x,y,r in wall: t_in,s_in = inWall(x,y,tx,ty,r),inWall(x,y,sx,sy,r) if t_in != s_in or (not t_in and isBetween(x,y,tx,ty,sx,sy) and isHide(x,y,r,a,b,c)): print("Safe") break else: print("Danger")
p00129
def inWall(x,y,x1,y1,r): return True if ((x-x1)**2+(y-y1)**2)**0.5 <= r + 1e-9 else False def isHide(x,y,r,a,b,c): D = abs(a*x+b*y+c)/(a**2+b**2)**0.5 return True if D <= r + 1e-9 else False def isBetween(x,y,tx,ty,sx,sy): a,b,c = (x-tx)**2+(y-ty)**2,(x-sx)**2+(y-sy)**2,(sx-tx)**2+(sy-ty)**2 if c > b and c > a: return True a,b,c = sorted([a,b,c]) return True if c-a-b <= 0 else False while 1: n = eval(input()) if n == 0: break wall = [list(map(int,input().split())) for i in range(n)] for i in range(eval(input())): tx,ty,sx,sy = list(map(int,input().split())) a,b,c = -(ty-sy),tx-sx,sx*ty-sy*tx for x,y,r in wall: t_in,s_in = inWall(x,y,tx,ty,r),inWall(x,y,sx,sy,r) if t_in != s_in or (not t_in and isBetween(x,y,tx,ty,sx,sy) and isHide(x,y,r,a,b,c)): print("Safe") break else: print("Danger")
def inWall(x,y,x1,y1,r): return True if ((x-x1)**2+(y-y1)**2)**0.5 <= r + 1e-9 else False def isHide(x,y,r,a,b,c): D = abs(a*x+b*y+c)/(a**2+b**2)**0.5 return True if D <= r + 1e-9 else False def isBetween(x,y,tx,ty,sx,sy): a,b,c = (x-tx)**2+(y-ty)**2,(x-sx)**2+(y-sy)**2,(sx-tx)**2+(sy-ty)**2 if c > b and c > a: return True a,b,c = sorted([a,b,c]) return True if c-a-b <= 0 else False while 1: n = eval(input()) if n == 0: break wall = [list(map(int,input().split())) for i in range(n)] for i in range(eval(input())): tx,ty,sx,sy = list(map(int,input().split())) a,b,c = -(ty-sy),tx-sx,sx*ty-sy*tx for x,y,r in wall: t_in,s_in = inWall(x,y,tx,ty,r),inWall(x,y,sx,sy,r) if t_in != s_in or (not t_in and isHide(x,y,r,a,b,c) and isBetween(x,y,tx,ty,sx,sy)): print("Safe") break else: print("Danger")
p00129
import math as M def R(A): return (A[0]**2+A[1]**2)**.5 def I(i): return [list(map(int,input().split())) for _ in [0]*i] def C(a,b): return a>b or abs(a-b)<1e-6 def f(e1): tx,ty,sx,sy=e1 x=[] for e2 in WP: wx,wy,r=e2 wt=[tx-wx,ty-wy]; rwt=R(wt) sw=[wx-sx,wy-sy]; rsw=R(sw) st=[tx-sx,ty-sy]; rst=R(st) F=[rwt<r,rsw<r] if rst==0: c=1 elif F==[1,1]: c=1 elif F==[1,0] or F==[0,1]: c=0 elif F==[0,0]: a=M.pi/2-M.acos(r/rsw) b=M.acos(round((sw[0]*st[0]+sw[1]*st[1])/rsw/rst,4)) if C(a,b) and C(rst**2,rsw**2-r**2): c=0 else: c=1 if c==0: return 0 x.append(c) return all(x) while 1: n=eval(input()) if n==0: break WP=I(n) P=I(eval(input())) for e in P: print(["Safe","Danger"][f(e)])
import math as M def R(A): return (A[0]**2+A[1]**2)**.5 def I(i): return [list(map(int,input().split())) for _ in [0]*i] def C(a,b): return a>b or abs(a-b)<1e-6 def f(e1): tx,ty,sx,sy=e1 x=[] st=[tx-sx,ty-sy]; rst=R(st) for e2 in WP: wx,wy,r=e2 wt=[tx-wx,ty-wy]; rwt=R(wt) sw=[wx-sx,wy-sy]; rsw=R(sw) F=[rwt<r,rsw<r] c=1 if F==[1,0] or F==[0,1]: return 0 elif F==[0,0]: a=M.pi/2-M.acos(r/rsw) b=M.acos(round((sw[0]*st[0]+sw[1]*st[1])/rsw/rst,4)) if C(a,b) and C(rst**2,rsw**2-r**2): return 0 x.append(c) return all(x) while 1: n=eval(input()) if n==0: break WP=I(n) P=I(eval(input())) for e in P: print(["Safe","Danger"][f(e)])
p00129
for roop in range(int(input())): h,m = list(map(int,input().split(":"))) s = 120*h + 2*m l = 24*m if l < s: l,s = s,l arg = l - s if l - s < 180*4 else 360*4-(l-s) if arg < 30*4: print("alert") elif arg < 90*4: print("warning") else : print("safe")
for roop in range(int(input())): h,m = list(map(int,input().split(":"))) s = 60*h + m l = 12*m if l < s: l,s = s,l arg = l - s if l - s < 180*2 else 360*2-(l-s) if arg < 30*2: print("alert") elif arg < 90*2: print("warning") else : print("safe")
p00135
#!/usr/bin/env python3 while(True): try: a,b=list(map(int, input().split())) except EOFError: break gcd=1 for i in range(1, a): if(a%i==0 and b%i==0): gcd=i lcm=int(a*b/gcd) print(("{0} {1}".format(gcd, lcm)))
#!/usr/bin/env python3 while(True): try: a,b=list(map(int, input().split())) except EOFError: break #euclidian algorithm r=a%b x,y=a,b while(r>0): x=y y=r r=x%y gcd=y lcm=int(a*b/gcd) print(("{0} {1}".format(gcd, lcm)))
p00005
# This program computes GCD and LCM # -*- coding: utf-8 import sys def gcd(a, b): for i in range(max([a, b]), 0, -1): if(a % i == 0 and b % i == 0): return i return 1 def lcm(a, b): for i in range(max([a, b]), a*b + 1): if(i % a == 0 and i % b == 0): return i return a*b for i in sys.stdin: try: line = [int(k) for k in i.split(" ")] g = gcd(line[0], line[1]) print((str(g) + " " + str(line[0]*line[1]//g))) # + str(lcm(line[0], line[1])) except: exit()
# This program computes GCD and LCM # -*- coding: utf-8 import sys def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): for i in range(max([a, b]), a*b + 1): if(i % a == 0 and i % b == 0): return i return a*b for i in sys.stdin: try: line = [int(k) for k in i.split(" ")] g = gcd(min(line), max(line)) print((str(g) + " " + str(line[0]*line[1]//g))) # + str(lcm(line[0], line[1])) except: exit()
p00005
# This program computes GCD and LCM # -*- coding: utf-8 import sys def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): for i in range(max([a, b]), a*b + 1): if(i % a == 0 and i % b == 0): return i return a*b for i in sys.stdin: try: line = [int(k) for k in i.split(" ")] g = gcd(min(line), max(line)) print((str(g) + " " + str(line[0]*line[1]//g))) # + str(lcm(line[0], line[1])) except: exit()
# This program computes GCD and LCM # -*- coding: utf-8 import sys def gcd(a, b): while b != 0: a, b = b, a % b return a for i in sys.stdin: try: line = [int(k) for k in i.split(" ")] g = gcd(min(line), max(line)) print((str(g) + " " + str(line[0]*line[1]//g))) except: exit()
p00005
import sys def gcd(a, b): ret = None if a <= b: large = b else: large = a for i in range(large, 0, -1): if i == 0 or i == 1: continue if a % i == 0 and b % i == 0: ret = i break return ret def lcm(a, b): ret = None lst = [a, b] while True: if a == b: ret = a break if a > b: b += lst[1] else: a += lst[0] return ret def main(): for line in sys.stdin.readlines(): a, b = [int(n) for n in line.split()] print("{0} {1}".format(gcd(a, b), lcm(a, b))) if __name__ == '__main__': main()
import sys def gcd(a, b): ret = None if a <= b: large = b else: large = a for i in range(large, 0, -1): if a % i == 0 and b % i == 0: ret = i break return ret def lcm(a, b): ret = None lst = [a, b] while True: if a == b: ret = a break if a > b: b += lst[1] else: a += lst[0] return ret def main(): for line in sys.stdin.readlines(): a, b = [int(n) for n in line.split()] print("{0} {1}".format(gcd(a, b), lcm(a, b))) if __name__ == '__main__': main()
p00005
import sys def gcd(a, b): ret = None if a == b: return a elif a < b: large = b else: large = a for i in range(large, 0, -1): if a % i == 0 and b % i == 0: ret = i break return ret def lcm(a, b): ret = None lst = [a, b] while True: if a == b: ret = a break if a > b: b += lst[1] else: a += lst[0] return ret def main(): for line in sys.stdin.readlines(): a, b = [int(n) for n in line.split()] print("{0} {1}".format(gcd(a, b), lcm(a, b))) if __name__ == '__main__': main()
import sys def gcd(a, b): ret = None if a > b: s = b else: s = a for i in range(s, 0, -1): if a % i == 0 and b % i == 0: ret = i break return ret def lcm(a, b): ret = None lst = [a, b] while True: if a == b: ret = a break if a > b: b += lst[1] else: a += lst[0] return ret def main(): for line in sys.stdin.readlines(): a, b = [int(n) for n in line.split()] print("{0} {1}".format(gcd(a, b), lcm(a, b))) if __name__ == '__main__': main()
p00005
from __future__ import (division, absolute_import, print_function, unicode_literals) import sys for line in sys.stdin: small, large = sorted(int(n) for n in line .split()) for i in range(small, 0, -1): if large % i == 0 and small % i == 0: gcd = i break for i in range(2, large + 1): if i * small % large == 0: lcm = i * small break print(gcd, lcm)
from __future__ import (division, absolute_import, print_function, unicode_literals) import sys for line in sys.stdin: small, large = sorted(int(n) for n in line .split()) for i in (n for n in range(small, 0, -1) if not small % n): if not large % i: gcd = i break for i in range(2, small + 1): if not i * large % small: lcm = i * large break print(gcd, lcm)
p00005
n = int(eval(input())) d_l = list(map(int,input().split())) count_dict = {} for i in range(n): count_dict[i] = 0 for val in d_l: count_dict[val] += 1 if d_l[0] != 0 or count_dict[0] != 1: ans = 0 else: ans = 1 for i in range(1,n): ans = ans*(count_dict[i-1]**count_dict[i]) if ans == 0: break print((ans%998244353))
n = int(eval(input())) d_l = list(map(int,input().split())) count_dict = {} for i in range(n): count_dict[i] = 0 for val in d_l: count_dict[val] += 1 if d_l[0] != 0 or count_dict[0] != 1: ans = 0 else: ans = 1 for i in range(1,n): ans = (ans*(count_dict[i-1]**count_dict[i])) %998244353 if ans == 0: break print(ans)
p02866
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) Ds = list(mapint()) if Ds[0]!=0: print((0)) exit(0) Ds.sort() mod = 998244353 from collections import Counter c = Counter(Ds) dmax = Ds[-1] if c[0]>1: print((0)) else: ans = 1 for i in range(1, dmax+1): ans *= pow(c[i-1], c[i], mod) ans %= mod print(ans)
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) Ds = list(mapint()) mod = 998244353 from collections import Counter c = Counter(Ds) if Ds[0]!=0: print((0)) elif c[0]>1: print((0)) else: ans = 1 for i in range(1, N): ans *= pow(c[i-1], c[i], mod) ans %= mod print(ans)
p02866
N = int(eval(input())) D = list(map(int, input().split())) mod = 998244353 ans = 1 A = [0]*(max(D)+1) for i in range(N): A[D[i]] += 1 #if D[0] != 0 or not all(D[1:]) or not all(A): # print(0) # exit() if D[0] != 0 or not all(D[1:]): print((0)) exit() for i in range(1, max(D)+1): # print(A[i]) if A[i] == 0: print((0)) exit() ans = ans * pow(A[i-1], A[i], mod) % mod print((ans % mod))
N = int(eval(input())) D = list(map(int, input().split())) mod = 998244353 ans = 1 A = [0]*(max(D)+1) for i in range(N): A[D[i]] += 1 if D[0] != 0 or not all(D[1:]) or not all(A): print((0)) exit() for i in range(1, max(D)+1): ans = ans * pow(A[i-1], A[i], mod) % mod print((ans % mod))
p02866
from collections import Counter n=int(eval(input())) d=list(map(int,input().split())) if d[0]!=0: print((0)) exit() c=Counter(d) c=sorted(list(c.items()),key=lambda x:x[0]) if c[0]!=(0,1): print((0)) exit() ans=1 check=1 for i in range(1,len(c)): if c[i][0]!=check: print((0)) exit() check+=1 ans*=c[i-1][1]**c[i][1] ans%=998244353 print((ans%998244353))
from sys import stdin nii=lambda:list(map(int,stdin.readline().split())) lnii=lambda:list(map(int,stdin.readline().split())) from collections import Counter n=int(eval(input())) d=lnii() mod=998244353 c=Counter(d) max_key=max(d) if d[0]!=0 or c[0]!=1: print((0)) exit() ans=1 patterns=1 for i in range(max_key+1): p_num=c[i] ans*=patterns**p_num ans%=mod patterns=p_num print(ans)
p02866
n=int(eval(input())) d=list(map(int,input().split())) c=[0]*(n+1) ans=1 for i in range(0,n): c[d[i]]+=1 if d[0]!=0 or c[0]!=1: print((0)) else: for j in range(1,n): if ans==0: break elif c[j]==0 and c[j+1]==0: ans+=0 else: ans*=c[j-1]**c[j] print((ans%998244353))
n=int(eval(input())) d=list(map(int,input().split())) x=max(d) li=[0]*(x+1) for i in range(n): li[d[i]]+=1 if d[0]!=0 or li[0]!=1: print((0)) else: ans=1 for i in range(2,len(li)): ans*=pow(li[i-1],li[i],998244353) print((ans%998244353))
p02866
mod = 998244353 n = int(eval(input())) A = [int(x) for x in input().split()] if A[0] != 0: print((0)) else: L = [0]*(n+1) for i in range(n): L[A[i]] += 1 if L[0]!=1: print((0)) else: ans = 1 for i in range(1,n+1): if L[i]>0: for k in range(L[i]): ans *= L[i-1] ans %= mod else: nxt = i break for j in range(nxt,n+1): if L[j] != 0: print((0)) break else: print(ans)
import sys def I(): return int(sys.stdin.readline()) def LI(): return [int(x) for x in sys.stdin.readline().split()] mod = 998244353 def main(): N = I() A = LI() if A[0] != 0: return 0 DistCnt = [0] * (max(A)+1) for i in range(N): DistCnt[A[i]] += 1 if DistCnt[0] != 1: return 0 ans = 1 for i in range(1,len(DistCnt)): ans *= pow(DistCnt[i-1],DistCnt[i],mod) ans %= mod return ans if __name__ == "__main__": print((main()))
p02866
import collections N = int(eval(input())) D = list(map(int,input().split())) if D[0] != 0: print((0)) exit() for i in range(max(D)): if i not in D: print((0)) exit() A = collections.Counter(D) A = list(A.items()) A.sort() ans = 1 for i in range(max(D)): ans *= A[i][1]**A[i+1][1] if ans >= 998244353: ans %= 998244353 print(ans)
import collections N = int(eval(input())) D = list(map(int,input().split())) if D[0] != 0 or 0 in D[1:]: print((0)) exit() A = collections.Counter(D) A = list(A.items()) A.sort() if len(A) != max(D) + 1: print((0)) exit() ans = 1 for i in range(max(D)): ans *= A[i][1]**A[i+1][1] if ans >= 998244353: ans %= 998244353 print(ans)
p02866
import collections N = int(eval(input())) D_list = list(map(int, input().split())) mod = 998244353 ans = 1 count_dir = collections.Counter(D_list) if max(D_list) >= N: ans = 0 else: for i in range(max(D_list) + 1): if i not in D_list: ans = 0 break if i >= 2: ans *= count_dir[i-1]**count_dir[i] if D_list[0] != 0 or count_dir[0] >= 2: ans = 0 print((ans%mod))
N = int(eval(input())) D_list = list(map(int, input().split())) mod = 998244353 ans = 1 count_list = [0]*(max(D_list) + 1) if max(D_list) >= N: ans = 0 else: for i in range(len(D_list)): count_list[D_list[i]] += 1 if count_list[1] == 0: ans = 0 else: for i in range(2, len(count_list)): if count_list[i] == 0: ans = 0 break ans *= count_list[i-1]**count_list[i] if D_list[0] != 0 or count_list[0] >= 2: ans = 0 print((ans%mod))
p02866
N = int(eval(input())) D = [int(s) for s in input().split()] if D[0] != 0: print((0)) exit() max_distance = [i+1 for i in range(max(D))] stock = 1 for i in max_distance: count_1 = D.count(i-1) count_2 = D.count(i) if count_1 == 0 or count_2 == 0: stock = 0 break stock *= count_1**count_2 print((stock%998244353))
N = int(eval(input())) D = [int(s) for s in input().split()] maximum = max(D) max_distance = [i+1 for i in range(maximum)] count_list = [0 for i in range(maximum+1)] for i in D: count_list[i] += 1 if D[0] != 0 or count_list[0] != 1: print((0)) exit() stock = 1 for i in max_distance: count_1 = count_list[i-1] count_2 = count_list[i] if count_1 == 0 or count_2 == 0: stock = 0 break stock *= count_1**count_2 print((stock%998244353))
p02866
N = int(eval(input())) D = list(map(int, input().split())) c = [0]*(N + 1) a = 0 ans = 1 mod = 998244353 for i, d in enumerate(D): if (i == 0) & (d != 0): print((0)) a = 1 break if (i != 0) & (d == 0): print((0)) a = 1 break c[d] += 1 if a == 0: for o in range(1, N): ans *= c[o]**c[o + 1] print((ans%mod))
N = int(eval(input())) D = list(map(int, input().split())) c = [0]*(N + 1) a = 0 ans = 1 temp = 0 pre = 1 mod = 998244353 c = 1 if D[0] != 0: print((0)) a = 1 if a == 0: D = sorted(D) for i, d in enumerate(D): if i == 0: continue if d == 0: print((0)) a = 1 break if temp != d: if (d - temp) != 1: print((0)) a = 1 break ans *= pre ** c temp = d pre = c c = 1 else: c += 1 if i == N-1: ans *= pre ** c if a == 0: print((ans%mod))
p02866
n = int(eval(input())) d = list(map(int,input().split())) db = [0] * (max(d)+1) MOD = 998244353 #距離iの頂点の数をdb[i]に保存 for i in range(n): db[d[i]] += 1 if (d[0] != 0)|(db[0] != 1): print((0)) exit() ans = 1 for i in range(len(db)-1): ans *= pow(db[i],db[i+1],MOD) print((ans%MOD))
n = int(eval(input())) d = list(map(int,input().split())) db = [0] * (max(d)+1) MOD = 998244353 #距離iの頂点の数をdb[i]に保存 for i in range(n): db[d[i]] += 1 if (d[0] != 0)|(db[0] != 1): print((0)) exit() ans = 1 for i in range(len(db)-1): ans *= db[i]**db[i+1]%MOD print((ans%MOD))
p02866
n = int(eval(input())) li = list(map(int, input().split())) li = sorted(li) count = 1 if not (1 in li and 0 in li): count = 0 else: for i in range(2,max(li) + 1): a = li.count(i-1) b = li.count(i) count *= a ** b print((count % 998244353))
n = int(eval(input())) li = list(map(int, input().split())) box = [0 for x in range(max(li)+1)] for i in li: box[i] += 1 count = 1 if len(box) > 2: for i in range(1, len(box)-1): count *= box[i] ** box[i+1] count %= 998244353 else: count = 1 if box[0] != 1 or li[0] != 0: count = 0 print((count % 998244353))
p02866
import sys input=sys.stdin.readline n=int(eval(input())) d=list(map(int,input().split())) if d[0]!=0: print((0)) exit() kyori=[] #1からmaxdまでの距離について、それぞれ何個のdが該当するかメモした配列 maxd=max(d) for i in range(0,maxd+1): kyori.append(d.count(i)) #1個目以外で距離0のやつある場合は停止。 if kyori[0]!=1: print((0)) exit() ans=1 for i in range(1,maxd): temp=kyori[i]**kyori[i+1] ans*=temp%998244353 ans=ans%998244353 print(ans)
import sys input=sys.stdin.readline n=int(eval(input())) d=list(map(int,input().split())) if d[0]!=0: print((0)) exit() #1からmaxdまでの距離について、それぞれ何個のdが該当するかメモした配列 maxd=max(d) kyori=[0]*(maxd+1) #計算量減らし、、 for i in d: kyori[i]+=1 #1個目以外で距離0のやつある場合は停止。 if kyori[0]!=1: print((0)) exit() ans=1 for i in range(1,maxd): temp=kyori[i]**kyori[i+1] ans*=temp%998244353 ans=ans%998244353 print(ans)
p02866
from collections import Counter from functools import reduce n = int(eval(input())) d = [int(s) for s in input().split()] if d[0] != 0: print((0)) quit(0) c = Counter(d) if c[0] != 1: print((0)) quit(0) print((reduce(lambda x, y: x * y, (c[x - 1] for x in d[1:]), 1) % 998244353))
from collections import Counter from functools import reduce n = int(eval(input())) d = (int(s) for s in input().split()) if next(d) != 0: print((0)) quit(0) c = Counter(d) if c[0] != 0: print((0)) quit(0) print((reduce(lambda x, y: x * y, (c[k - 1] ** x if k > 1 else 1 for k, x in list(c.items())), 1) % 998244353))
p02866
N = int(eval(input())) D = list(map(int, input().split())) mod = 998244353 counter = [0] * N for d in D: counter[d] += 1 if counter[0] != 1: print((0)) exit() ans = 1 for d in D[1:]: ans *= counter[d-1] % mod print((ans % mod))
N = int(eval(input())) D = list(map(int, input().split())) mod = 998244353 counter = [0] * N for d in D: counter[d] += 1 if counter[0] != 1: print((0)) exit() ans = 1 for d in D[1:]: ans = ans * counter[d-1] % mod print(ans)
p02866
N = int(eval(input())) array = list(map(int, input().split())) if array[0] != 0: print((0)) exit() array.sort() if 1 in array and len(set(array[1:])) == 1: print((1)) exit() if not (2 in array): print((0)) exit() if 0 in array[1:]: print((0)) exit() index = array.index(2) count = 1 count_old = array.count(1) ans = 1 first = array[index] for i in range(index,N-1): if first != array[i+1]: if first != array[i+1] - 1: print((0)) exit() ans *= count_old ** count count_old = count count = 1 else: count += 1 first = array[i+1] ans %= 998244353 ans *= count_old ** count ans %= 998244353 print(ans)
MOD = 998244353 N = int(eval(input())) D = list(map(int, input().split())) if D[0] != 0: print((0)) exit() D_2 = [0]*(max(D)+1) for i in D: D_2[i] += 1 if D_2[0] != 1: print((0)) exit() ans = 1 for i in range(1,max(D)+1): ans *= D_2[i-1]**D_2[i] ans %= MOD print(ans)
p02866
n = int(eval(input())) D = list(map(int, input().split())) if D[0] != 0: ans = 0 else: ans = 1 cnt = 1 for i in range(max(D)+1): ans = ans * (cnt ** D.count(i)) % 998244353 cnt = D.count(i) print(ans)
n = int(eval(input())) D = list(map(int, input().split())) if D[0] != 0 or 0 in D[1:]: ans = 0 else: num = [0 for i in range(max(D)+1)] ans = 1 cnt = 1 for i in range(n): num[D[i]] += 1 for i in range(len(num)): ans = ans * (cnt ** num[i]) % 998244353 cnt = num[i] print(ans)
p02866
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutations from operator import add, mul, sub sys.setrecursionlimit(100000) input = sys.stdin.readline INF = 2**62-1 def read_int(): return int(input()) def read_int_n(): return list(map(int, input().split())) def read_float(): return float(input()) def read_float_n(): return list(map(float, input().split())) def read_str(): return input().strip() def read_str_n(): return list(map(str, input().split())) def error_print(*args): print(*args, file=sys.stderr) def mt(f): import time def wrap(*args, **kwargs): s = time.time() ret = f(*args, **kwargs) e = time.time() error_print(e - s, 'sec') return ret return wrap class Mod: def __init__(self, m): self.m = m def add(self, a, b): return (a + b) % self.m def sub(self, a, b): return (a - b) % self.m def mul(self, a, b): return ((a % self.m) * (b % self.m)) % self.m def div(self, a, b): return self.mul(a, pow(b, self.m-2, self.m)) def pow(self, a, b): return pow(a, b, self.m) @mt def slv(N, D): if D[0] != 0: return 0 C = Counter(D) if C[0] != 1: return 0 ans = 1 M = Mod(998244353) for i in range(max(D)): if C[i] == 0: return 0 ans = M.mul(ans, M.pow(C[i], C[i+1])) return ans def main(): N = read_int() D = read_int_n() print(slv(N, D)) if __name__ == '__main__': main()
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutations from operator import add, mul, sub sys.setrecursionlimit(100000) input = sys.stdin.readline INF = 2**62-1 def read_int(): return int(input()) def read_int_n(): return list(map(int, input().split())) def read_float(): return float(input()) def read_float_n(): return list(map(float, input().split())) def read_str(): return input().strip() def read_str_n(): return list(map(str, input().split())) def error_print(*args): print(*args, file=sys.stderr) def mt(f): import time def wrap(*args, **kwargs): s = time.time() ret = f(*args, **kwargs) e = time.time() error_print(e - s, 'sec') return ret return wrap class Mod: def __init__(self, m): self.m = m def add(self, a, b): return (a + b) % self.m def sub(self, a, b): return (a - b) % self.m def mul(self, a, b): return ((a % self.m) * (b % self.m)) % self.m def div(self, a, b): return self.mul(a, pow(b, self.m-2, self.m)) def pow(self, a, b): return pow(a, b, self.m) @mt def slv(N, D): if D[0] != 0: return 0 C = Counter(D) if C[0] != 1: return 0 ans = 1 M = Mod(998244353) for i in range(max(D)): ans = M.mul(ans, M.pow(C[i], C[i+1])) return ans def main(): N = read_int() D = read_int_n() print(slv(N, D)) if __name__ == '__main__': main()
p02866
n=int(eval(input())) d=list(map(int,input().split())) mod=998244353 if d[0]!=0: print((0)) exit() if 0 in d[1:]: print((0)) exit() ans=1 from collections import Counter c=Counter(d) for i in range(1,max(d)+1): if i not in list(c.keys()): print((0)) exit() ans*=(c[i-1]**c[i]) ans%=mod print(ans)
n=int(eval(input())) d=list(map(int,input().split())) mod=998244353 if d[0]!=0: print((0)) exit() if 0 in d[1:]: print((0)) exit() ans=1 from collections import Counter c=Counter(d) for i in range(1,max(d)+1): if not i in c: print((0)) exit() ans*=(c[i-1]**c[i]) ans%=mod print(ans)
p02866
from collections import Counter n = int(eval(input())) d = list(map(int, input().split())) if d[0] != 0: print((0)) exit() cnt = Counter(d) if cnt[0] != 1: print((0)) exit() ans = 1 for i in d: if i != 0: ans *= cnt[i-1] % 998244353 print((ans % 998244353))
from collections import Counter n = int(eval(input())) d = list(map(int, input().split())) if d[0] != 0: print((0)) exit() cnt = Counter(d) if cnt[0] != 1: print((0)) exit() ans = 1 for i in d: if i != 0: ans = (ans * cnt[i-1]) % 998244353 print(ans)
p02866
if __name__ == "__main__": mod = 998244353 n = int(eval(input())) d = list(map(int, input().split())) if d[0] > 0: print('0') exit() d.sort() d.pop(0) if d[0] == 0: print('0') exit() tmp = 1 ans = 1 max_num = max(d) for i in range(1, max_num+1): if i+1 in d: count = d.index(i+1) elif i+1 == max_num+1: count = len(d) else: print('0') exit() ans *= tmp ** count ans %= mod tmp = count d = d[count:] print(ans)
if __name__ == "__main__": mod = 998244353 n = int(eval(input())) d = list(map(int, input().split())) if d[0] > 0: print('0') exit() if len(d) == 1: print('1') exit() d.sort() d.pop(0) if d[0] == 0: print('0') exit() tmp = 1 ans = 1 max_num = max(d) dic = dict() for i in range(n-1): if d[i] in dic: dic[d[i]] += 1 else: dic[d[i]] = 1 for i in range(1, max_num+1): if i in dic: count = dic[i] else: print('0') exit() if count == 0: print('0') exit() ans *= tmp ** count ans %= mod tmp = count print(ans)
p02866
# 最初dは与えられる距離だと思ってて「サンプルケース1は3じゃね?」とか思ってて2時間経過した # 落ち着いて読んだら最小の辺の数だった from collections import Counter n = int(eval(input())) arr = list(map(int, input().split())) if arr[0] != 0: print((0)) exit() arr = sorted(list(Counter(arr).items()), key=lambda x: x[0]) if arr[0][1] > 1: print((0)) exit() mod = 998244353 ans = 1 tmp = 1 for i in range(1, len(arr)): if arr[i][0] != i: print((0)) exit() ans *= pow(tmp, arr[i][1]) ans %= mod tmp = arr[i][1] print(ans)
n = int(eval(input())) d = {} mod = 998244353 max_v = 0 lis = list(map(int, input().split())) # 先頭はかならず0 if lis[0] != 0: print((0)) exit() for v in lis: if v not in d: d[v] = 1 else: d[v] += 1 max_v = max(max_v, v) # 0はひとつだけ if 0 not in d or d[0] > 1: print((0)) exit() ans = 1 # 木を作ることができるならば1~max_vまでの数字がそれぞれ1つ以上存在する for i in range(1, max_v + 1): if i not in d or i - 1 not in d: ans *= 0 else: ans *= pow(d[i - 1], d[i], mod) ans %= mod print(ans)
p02866
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 998244353 def resolve(): n = int(eval(input())) D = list(map(int, input().split())) tree = [0 for _ in range(max(D) + 1)] for i in range(n): idx = D[i] tree[idx] += 1 if D[0] != 0 or tree[0] != 1 or 0 in tree: print((0)) exit() res = 1 for i in range(len(tree) - 1): res *= pow(tree[i], tree[i + 1], mod) print((res % mod)) if __name__ == '__main__': resolve()
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 998244353 def resolve(): n = int(eval(input())) D = list(map(int, input().split())) MAX_L = max(D) + 1 cnt = [0] * MAX_L for d in D: cnt[d] += 1 if cnt[0] != 1 or D[0] != 0: print((0)) exit() res = 1 for i in range(1, MAX_L): if cnt[i] == 0: print((0)) break res *= pow(cnt[i - 1], cnt[i], mod) res %= mod else: print(res) if __name__ == '__main__': resolve()
p02866
from collections import Counter N = int(eval(input())) D = list(map(int, input().split())) mod = 998244353 c = Counter(D) m = max(c.keys()) if D[0] == 0 and c[0] == 1: ans = 1 for i in range(1, m+1): ans *= c[i-1]**c[i] % mod ans %= mod print(ans) else: print((0))
from collections import Counter N = int(eval(input())) D = list(map(int, input().split())) mod = 998244353 c = Counter(D) m = max(c.keys()) if D[0] == 0 and c[0] == 1: ans = 1 for i in range(1, m+1): ans *= c[i-1]**c[i] ans %= mod print(ans) else: print((0))
p02866
from collections import Counter N = int(eval(input())) D = list(map(int, input().split())) mod = 998244353 c = Counter(D) m = max(c.keys()) if D[0] == 0 and c[0] == 1: ans = 1 for i in range(1, m+1): ans *= c[i-1]**c[i] ans %= mod print(ans) else: print((0))
from collections import Counter N = int(eval(input())) D = list(map(int, input().split())) mod = 998244353 c = Counter(D) m = max(c.keys()) if D[0] == 0 and c[0] == 1: ans = 1 for i in D[1:]: ans *= c[i-1] ans %= mod print(ans) else: print((0))
p02866
# coding: utf-8 N = int(eval(input())) D = list(map(int, input().split())) l = [0] * N top = max(D) mod = 998244353 for i in range(N): l[D[i]] += 1 # print(*l) ans = 1 for i in range(1, top+1): if l[i] != 0: ans *= l[i-1] ** l[i] if l[i] == 0: print((0)) exit() ans = ans % mod if D[0] != 0: ans = 0 if l[0] != 1: ans = 0 print(ans)
# coding: utf-8 N = int(eval(input())) D = list(map(int, input().split())) l = [0] * N top = max(D) mod = 998244353 for i in range(N): l[D[i]] += 1 ans = 1 for i in range(1, top+1): if l[i] != 0: ans *= l[i-1] ** l[i] if l[i] == 0: print((0)) exit() ans = ans % mod if D[0] != 0: ans = 0 if l[0] != 1: ans = 0 print(ans)
p02866
from collections import Counter N = int(eval(input())) D = list(map(int, input().split())) MOD = 998244353 # 条件をみたす木が存在するには D1 = 0 が必要 if D[0] != 0: print((0)) exit() # 0 == 1 ctr = Counter(D) if ctr[0] != 1: print((0)) exit() ans = 1 for i in range(len(ctr)-1): ans *= pow(ctr[i], ctr[i+1], MOD) ans %= MOD print(ans)
from collections import Counter def resolve(): MOD = 998244353 N = int(eval(input())) D = list(map(int, input().split())) if D[0] != 0: print((0)) return CNT = Counter(D) if CNT[0] > 1: # 距離0は1個 print((0)) return ans = 1 for i in range(1, max(D) + 1): ans *= pow(CNT[i - 1], CNT[i], MOD) ans %= MOD print(ans) if __name__ == "__main__": resolve()
p02866
from collections import Counter def resolve(): MOD = 998244353 N = int(eval(input())) D = list(map(int, input().split())) if D[0] != 0: print((0)) return CNT = Counter(D) if CNT[0] > 1: # 距離0は1個 print((0)) return ans = 1 for i in range(1, max(D) + 1): ans *= pow(CNT[i - 1], CNT[i], MOD) ans %= MOD print(ans) if __name__ == "__main__": resolve()
def resolve(): MOD = 998244353 N = int(eval(input())) D = list(map(int, input().split())) if D[0] != 0: print((0)) return CNT = [0] * N for i in D: CNT[i] += 1 if CNT[0] > 1: print((0)) return ans = 1 for i in range(1, N): ans *= pow(CNT[i - 1], CNT[i], MOD) ans %= MOD print(ans) if __name__ == "__main__": resolve()
p02866
#b n=int(eval(input())) d=[int(i) for i in input().split()] import collections c = collections.Counter(d) m=998244353 ans=1 if d[0]!=0 or set(d)!=set(range(len(set(d)))) or 0 in d[1:]: print((0)) else: for i in range(1,len(c)): ans = (ans* c[i-1]**c[i]) %m print(ans)
n=int(eval(input())) d=list(map(int,input().split())) from collections import Counter c=Counter(d) mod=998244353 ans=1 key=set(c.keys()) if d[0]==0 and c[0]==1 and set(range(len(key))) == key: for i in range(len(key)): #print(i,c[i],c[i+1],c[i]**c[i+1]) ans=ans*c[i]**c[i+1] %mod else: ans=0 print(ans)
p02866
import sys read = lambda: sys.stdin.readline().rstrip() def counting_tree(N, D): import collections tot = 1 cnt = collections.Counter(D) """ cnt = [0]*N for i in D: cnt[i]+=1 """ for i in D[1:]: tot = tot * cnt[i-1]%998244353 return tot if D[0]==0 else 0 def main(): N0 = int(read()) D0 = tuple(map(int, read().split())) res = counting_tree(N0, D0) print(res) if __name__ == "__main__": main()
import sys read = lambda: sys.stdin.readline().rstrip() class Solution(object): def counting_tree(self, N, D): #import collections tot = 1 #cnt = collections.Counter(D) cnt = [0]*N for i in D: cnt[i]+=1 for i in D[1:]: tot = tot * cnt[i-1]%998244353 return tot if D[0]==0 else 0 def main(): N0 = int(read()) D0 = tuple(map(int, read().split())) res = Solution().counting_tree(N0, D0) print(res) if __name__ == "__main__": main()
p02866
from collections import Counter import sys MOD = 998244353 def main(): n, *d = list(map(int, sys.stdin.buffer.read().split())) D = Counter(d) if D[0] != 1: print((0)) else: ans = 1 for i in d[1:]: ans = ans*D[i-1]%MOD print((ans % MOD)) if __name__ == '__main__': main()
from collections import Counter import sys MOD = 998244353 def main(): n, *d = list(map(int, sys.stdin.buffer.read().split())) e = [0]*n for i in d: e[i] += 1 ans = e[0] for i in d[1:]: ans *= e[i-1] ans %= MOD print(ans) if __name__ == '__main__': main()
p02866
from collections import Counter import sys MOD = 998244353 def main(): n, *d = list(map(int, sys.stdin.buffer.read().split())) e = [0]*n for i in d: e[i] += 1 ans = e[0] for i in d[1:]: ans *= e[i-1] ans %= MOD print(ans) if __name__ == '__main__': main()
import sys MOD = 998244353 def main(): n, *d = list(map(int, sys.stdin.buffer.read().split())) e = [0]*n for i in d: e[i] += 1 ans = e[0] for i in d[1:]: ans *= e[i-1] ans %= MOD print(ans) if __name__ == '__main__': main()
p02866
import sys MOD = 998244353 def main(): n, *d = list(map(int, sys.stdin.buffer.read().split())) e = [0]*n for i in d: e[i] += 1 ans = e[0] for i in d[1:]: ans *= e[i-1] ans %= MOD print(ans) if __name__ == '__main__': main()
import sys MOD = 998244353 def main(): n, *d = list(map(int, sys.stdin.buffer.read().split())) e = [0]*n for i in d: e[i] += 1 ans = e[0] for i in d[1:]: ans = ans*e[i-1] % MOD print(ans) if __name__ == '__main__': main()
p02866
from collections import Counter n = int(eval(input())) d = list(map(int, input().split())) count = Counter(d) if d[0] != 0: print((0)) #print(count[0]) #print(len(count)) #print(count.keys()) #print(count.items()) elif count[0] != 1: print((0)) else: ans = 1 tmp = 1 len_d = len(d) for i in range(1, len_d+1): ans *= tmp**count[i] #print(ans) tmp = count[i] print((ans%998244353))
from collections import Counter n = int(eval(input())) d = list(map(int, input().split())) count = Counter(d) if d[0] != 0: print((0)) #print(count[0]) #print(len(count)) #print(count.keys()) #print(count.items()) elif count[0] != 1: print((0)) else: ans = 1 tmp = 1 max_d = max(d) for i in range(1, max_d+1): ans *= tmp**count[i] #print(ans) tmp = count[i] print((ans%998244353))
p02866
n = int(eval(input())) a = list(map(int, input().split())) if a[0] > 0 or a.count(0) > 1: print((0)) exit() a = sorted(a) dp = [0]*(n+1) dp[0] = 1 count_list = [0]*n count_list[0] = 1 for i in range(1, n): num = a[i] count_list[num] += 1 dp[a[i]] = dp[num-1] * count_list[num-1] ** count_list[num] % 998244353 print((dp[a[n-1]]))
n = int(eval(input())) a = list(map(int, input().split())) if a[0] > 0 or a.count(0) > 1: print((0)) exit() a = sorted(a) dp = [0]*(n+1) dp[0] = 1 count_list = [0]*n count_list[0] = 1 for i in range(1, n): count_list[a[i]] += 1 for i in range(1, a[n-1]+1): dp[i] = dp[i-1] * count_list[i-1] ** count_list[i] % 998244353 print((dp[a[n-1]]))
p02866
n = int(eval(input())) d = list(map(int, input().split())) a = [0] * n for i in range(n): a[d[i]] += 1 if a[0] == 1 and d[0] == 0: ans = 1 for i in range(1, n): ans *= a[i-1]**a[i] print((ans % 998244353)) else: print((0))
n = int(eval(input())) d = list(map(int, input().split())) a = [0] * n for i in range(n): a[d[i]] += 1 if a[0] == 1 and d[0] == 0: ans = 1 for i in range(1, n): ans *= a[i-1]**a[i] ans %= 998244353 print(ans) else: print((0))
p02866
_,d=open(0) *d,=list(map(int,d.split())) e=[0]*10**5 for i in d:e[i]+=1 a=d[0]<1==e[0] for x,y in zip(e,e[1:]):a*=x**y print((a%998244353))
_,d=open(0) *d,=list(map(int,d.split())) e=[0]*-~max(d) for i in d:e[i]+=1 a=d[0]<1==e[0] for x,y in zip(e,e[1:]):a*=x**y print((a%998244353))
p02866
_,d=open(0) *d,=list(map(int,d.split())) e=[0]*10**5 for i in d:e[i]+=1 a=d[0]<1==e[0] for x,y in zip(e,e[1:]):a*=x**y print((a%998244353))
_,d=open(0) *d,=list(map(int,d.split())) e=[0]*-~max(d) for i in d:e[i]+=1 a=d[0]<1==e[0] for x,y in zip(e,e[1:]):a*=x**y print((a%998244353))
p02866
def main(): n,*d=list(map(int,open(0).read().split())) e=[0]*n for i in d:e[i]+=1 a=1if d[0]<1else 0 for i in d[1:]:a=a*e[i-1]%998244353 print(a) main()
def main(): import sys n,*d=list(map(int,sys.stdin.buffer.read().split())) e=[0]*n for i in d:e[i]+=1 a=1if d[0]<1else 0 for i in d[1:]:a=a*e[i-1]%998244353 print(a) main()
p02866
import sys def answerA(): input = sys.stdin.readline N = int(eval(input())) print(((N-1) // 2)) def answer(): input = sys.stdin.readline N = int(eval(input())) distances = list(map(int, input().split())) maximum = max(distances) counts = [] for d in range(maximum + 1): counts.append(distances.count(d)) result = 1 mod = 998244353 if 0 in counts: result = 0 elif 0 in distances[1:]: result = 0 else: for d in distances[1:]: result *= counts[d-1] result %= mod print(result) if __name__ == '__main__': answer()
def answer(): N = int(eval(input())) distances = list(map(int, input().split())) result = 1 mod = 998244353 if distances[0] != 0: result = 0 elif 0 in distances[1:]: result = 0 else: distances.sort() maximum = distances[-1] counts = [0] * (maximum + 1) counts[0] = 1 for d in distances[1:]: counts[d] += 1 result *= counts[d-1] result %= mod print(result) if __name__ == '__main__': answer()
p02866
a = int(eval(input())) l = list(map(int,input().split())) MOD = 998244353 dp = [0]*a for i in l: dp[i]+=1 res = 1 # print(dp) if dp[0] != 1 and l[0]!=0: print((0)) exit() for i in l[1:]: # print(i) res*=dp[i-1] print((res%MOD))
a = int(eval(input())) l = list(map(int,input().split())) MOD = 998244353 dp = [0]*a for i in l: dp[i]+=1 res = 1 # print(dp) if dp[0] != 1 and l[0]!=0: print((0)) exit() for i in l[1:]: # print(i) res*=dp[i-1] res%=MOD print(res)
p02866
a = int(eval(input())) l = list(map(int,input().split())) MOD = 998244353 dp = [0]*a for i in l: dp[i]+=1 res = 1 # print(dp) if l[0]!=0: print((0)) exit() for i in l[1:]: # print(i) res*=dp[i-1] res%=MOD print((res%MOD))
a = int(eval(input())) l = list(map(int,input().split())) d = [0]*a for i in l: d[i]+=1 r =1 if l[0]!=0: print((0)) exit() for i in l[1:]: r=r*d[i-1]%998244353 print(r)
p02866
n=int(eval(input())) d=list(map(int,input().split())) q=[] #from collections import Counter #q=Counter(d) for i in range(max(d)+1): q.append(d.count(i)) if q[0]!=1 or d[0]!=0: print((0)) exit() ans=1 for i in range(1,max(d)+1): ans*=q[i-1]**q[i] if ans == 0: break print((ans%998244353))
n=int(eval(input())) d=list(map(int,input().split())) q=[0]*(max(d)+1) #from collections import Counter #q=Counter(d) for i in range(len(d)): q[d[i]]+=1 if q[0]!=1 or d[0]!=0: print((0)) exit() ans=1 for i in range(1,max(d)+1): ans*=q[i-1]**q[i] if ans == 0: break print((ans%998244353))
p02866
import collections import sys n = int(eval(input())) d = list(map(int, input().split())) cnt = collections.Counter(d) if d[0]!=0: print((0)) sys.exit(0) if cnt[0]!=1: print((0)) sys.exit(0) p = 1 for i in range(1,max(d)+1): if cnt[i] == 0: print((0)) sys.exit(0) else: p = (p * pow(cnt[i-1], cnt[i], 998244353))%998244353 print(p)
import collections import sys n = int(eval(input())) d = list(map(int, input().split())) cnt = collections.Counter(d) if d[0]!=0: print((0)) sys.exit(0) if cnt[0]!=1: print((0)) sys.exit(0) p = 1 for i in range(1,max(d)+1): p = (p * pow(cnt[i-1], cnt[i], 998244353))%998244353 print(p)
p02866
def main(): N = eval(input()) D = list(map(int,input().split())) M = max(D) countlist=[0] * (M + 1) ans=1 for i in D: countlist[i]+=1 if countlist[0]!=1 : ans = 0 else : if D[0]!=0 : ans = 0 else: for i in range(2,M+1): ans *= countlist[i-1]**countlist[i] print((ans%998244353)) if __name__ == "__main__": main()
def main(): N = eval(input()) D = list(map(int,input().split())) M = max(D) countlist=[0] * (M + 1) ans=1 for i in D: countlist[i]+=1 if countlist[0]!=1 : ans = 0 else : if D[0]!=0 : ans = 0 else: for i in range(2,M+1): ans = ans * (countlist[i-1]**countlist[i]) % 998244353 print(ans) if __name__ == "__main__": main()
p02866
from collections import Counter N = int(eval(input())) D = list(map(int, input().split())) MOD = 998244353 def calc(): if D[0] != 0: return 0 if sum(D) < N-1: return 0 c = Counter(D) ret = 1 tmpkey = 0 tmpvalue = 0 for key in sorted(c.keys()): if key - tmpkey >= 2: return 0 if key == 0: if c[key] >= 2: return 0 else: ret *= (tmpvalue ** c[key]) % MOD ret %= MOD tmpkey = key tmpvalue = c[key] return ret print((calc()))
from collections import Counter N = int(eval(input())) D = list(map(int, input().split())) MOD = 998244353 # 厳密にはmax(D)+1の長さがあれば正常系は通るが、余分に取っておく count = [0] * N for d in D: count[d] += 1 def calc(): if D[0] != 0: return 0 ret = 1 for i in range(N): if i == 0: if count[i] >= 2: return 0 else: ret *= (count[i-1] ** count[i]) % MOD ret %= MOD return ret print((calc()))
p02866
from collections import defaultdict N = int(eval(input())) D = list(map(int, input().split())) MOD = 998244353 p = defaultdict(int) for d in D: p[d] += 1 if p[0] == 1 and D[0] == 0: ans = 1 for i in range(N + 1): ans *= p[i] ** p[i + 1] ans %= MOD print((ans % MOD)) else: print((0))
from collections import defaultdict N = int(eval(input())) D = list(map(int, input().split())) MOD = 998244353 p = defaultdict(int) for d in D: p[d] += 1 if p[0] == 1 and D[0] == 0: ans = 1 for i in range(max(D)): ans *= p[i] ** p[i + 1] ans %= MOD if ans == 0: break print(ans) else: print((0))
p02866
#!/usr/bin/env python3 import sys MOD = 998244353 # type: int def baai(n1, n2): return(n1**n2%MOD) def solve(N: int, D: "List[int]"): cn=[0]*N for i in range(N): cn[D[i]]+=1 if D[0]!=0: print((0)) else: answer=1 bak=cn[0] kyo=1 hen=1 while True: if kyo >= N: while True: pass cnt=cn[kyo] hen+=cnt if cnt==0: break answer=answer*baai(bak, cnt)%MOD bak=cnt kyo+=1 if hen==N: print((answer%MOD)) else: print((0)) return # Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int D = [int(next(tokens)) for _ in range(N)] # type: "List[int]" solve(N, D) if __name__ == '__main__': main()
#!/usr/bin/env python3 import sys MOD = 998244353 # type: int def baai(n1, n2): return(n1**n2%MOD) def solve(N: int, D: "List[int]"): cn=[0]*(N + 1) for i in range(N): cn[D[i]]+=1 if D[0]!=0: print((0)) else: answer=1 bak=cn[0] kyo=1 hen=1 while True: cnt=cn[kyo] hen+=cnt if cnt==0: break answer=answer*baai(bak, cnt)%MOD bak=cnt kyo+=1 if hen==N: print((answer%MOD)) else: print((0)) return # Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int D = [int(next(tokens)) for _ in range(N)] # type: "List[int]" solve(N, D) if __name__ == '__main__': main()
p02866
from collections import Counter def solve(n, arr): if arr[0] != 0: return 0 c = Counter(arr) if c[0] != 1: return 0 for i in range(max(c) + 1): if i not in c: return 0 c = list(c.items()) c.sort() prev = 1 ans = 1 mod = 998244353 for _, i in c[1:]: ans *= pow(prev, i) % mod ans %= mod prev = i return ans n = int(eval(input())) arr = list(map(int, input().split())) print((solve(n, arr)))
from collections import Counter def solve(n, arr): if arr[0] != 0: return 0 c = Counter(arr) if c[0] != 1: return 0 for i in range(max(c) + 1): if i not in c: return 0 c = list(c.items()) c.sort() prev = 1 ans = 1 mod = 998244353 for _, i in c[1:]: ans *= prev**i % mod ans %= mod prev = i return ans n = int(eval(input())) arr = list(map(int, input().split())) print((solve(n, arr)))
p02866
mod = 998244353 n = int(eval(input())) d = list(map(int, input().split())) if d[0] != 0: print((0)) exit() lis = [] for i in range(n): lis.append(d.count(i)) if lis[0] != 1: print((0)) exit() ans = 1 for i in range(1, n): ans *= pow(lis[i-1], lis[i], mod) ans %= mod print(ans)
mod = 998244353 n = int(eval(input())) d = list(map(int, input().split())) if d[0] != 0: print((0)) exit() lis = [0] * n for i in d: lis[i] += 1 if lis[0] != 1: print((0)) exit() ans = 1 for i in range(1, n): ans *= pow(lis[i-1], lis[i], mod) ans %= mod print(ans)
p02866
from collections import Counter mod=998244353 n=int(eval(input())) D=list(map(int,input().split())) Count=Counter(D) if Count[0]!=1 or D[0]!=0:print((0));exit() ans=1 for i in range(1,max(Count)+1): ans *=Count[i-1]**Count[i] ans %=mod print(ans)
from collections import Counter mod=998244353 n=int(eval(input())) D=list(map(int,input().split())) Count=Counter(D) if D[0]!=0 or Count[0]!=1:print((0));exit() ans=1 for i in range(1,max(Count)+1): ans *=Count[i-1]**Count[i] ans %=mod print(ans)
p02866
MOD = 998244353 n = int(eval(input())) distances = list([int(x) for x in input().split()]) # 最初が0であることを確認 canSolve = True ans = 1 if distances[0] != 0: canSolve = False ans = 0 dist_list = {} if canSolve: for i in distances: if i in list(dist_list.keys()): dist_list[i] += 1 else: dist_list[i] = 1 keys = list(dist_list.keys()) keys.sort() keys.reverse() bigger = None smaller = None for v in keys: if bigger is None: bigger = dist_list[v] continue elif smaller is None: smaller = dist_list[v] else: bigger = smaller smaller = dist_list[v] ans *= (smaller**bigger) ans = ans % MOD print(ans)
MOD = 998244353 n = int(eval(input())) distances = list([int(x) for x in input().split()]) # 最初が0であることを確認 canSolve = True ans = 1 if distances[0] != 0: canSolve = False ans = 0 dist_list = {} if canSolve: for i in distances: if i in list(dist_list.keys()): dist_list[i] += 1 else: dist_list[i] = 1 keys = list(dist_list.keys()) keys.sort() keys.reverse() bigger = None smaller = None pre_v = None for v in keys: if bigger is None: bigger = dist_list[v] pre_v = v continue elif smaller is None: smaller = dist_list[v] else: bigger = smaller smaller = dist_list[v] if v==0 and smaller > 1: ans = 0 if v == pre_v - 1: ans *= (smaller**bigger) ans = ans % MOD pre_v = v else: ans = 0 print(ans)
p02866
n = int(eval(input())) d = list(map(int, input().split())) x = [] for i in range(max(d)+1): x.append(d.count(i)) ans = 1 if d[0] == 0 and x[0] == 1: for i in range(1, len(x)-1): ans = ans * (x[i]**x[i+1]) else: ans = 0 print((ans%998244353))
n = int(eval(input())) d = list(map(int, input().split())) dd = sorted(d) c = [] j = 0 for i in range(max(d)+1): tmp = 0 while dd[j] == i: tmp += 1 j += 1 if j == n: break c.append(tmp) ans = 1 if d[0] == 0 and d.count(0) == 1 and c.count(0) == 0: for i in range(1, max(d)): ans = ans * (c[i]**c[i+1]) else: ans = 0 print((ans%998244353))
p02866
from collections import Counter n = int(eval(input())) d = list(map(int, input().split())) mod = 998244353 a = sorted(list(set(d))) if d[0] != 0: ans = 0 elif a[-1] != len(a)-1: ans = 0 else: c = sorted(Counter(d).items()) if c[0] != (0, 1): ans = 0 else: ans = 1 pre = 1 for k, v in c: ans *= pre ** v ans %= mod pre = v print(ans)
n = int(eval(input())) d = list(map(int, input().split())) mod = 998244353 a = [0] * n for d_ in d: a[d_] += 1 res = d[0] == 0 and a[0] == 1 pre = 1 for a_ in a: res *= pre ** a_ res %= mod pre = a_ print(res)
p02866
n = int(eval(input())) d = list(map(int, input().split())) mod = 998244353 a = [0] * n for d_ in d: a[d_] += 1 res = d[0] == 0 and a[0] == 1 pre = 1 for a_ in a: res *= pre ** a_ res %= mod pre = a_ print(res)
n = int(eval(input())) d = list(map(int, input().split())) mod = 998244353 a = [0] * n for d_ in d: a[d_] += 1 res = d[0] == 0 and a[0] == 1 pre = 1 for a_ in a: res = res * pre ** a_ % mod pre = a_ print(res)
p02866
n=int(eval(input())) d=list(map(int,input().split())) maxd=max(d) import collections counter=collections.Counter(d) if d[0]!=0 or counter[0]!=1: print((0)) else: a=1 ans=1 for i in range(1,maxd+1): if i not in counter: print((0)) break else: b=counter[i] ans*=(a**b) a=b else: print((ans%998244353))
n=int(eval(input())) d=list(map(int,input().split())) if d[0]!=0: print((0)) exit(0) m=max(d) counts=[0]*(m+1) import collections counter=collections.Counter(d) for key,val in list(counter.items()): counts[key]=val if counts[0]!=1: print((0)) exit(0) ans=1 div=998244353 for i in range(1,len(counts)): ans*=pow(counts[i-1],counts[i],div) ans%=div print(ans)
p02866