This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#A | |
from fractions import Fraction | |
N=1000 | |
a=[0 for i in range(N+1)] | |
a[1]=1 | |
for n in range(1,N): | |
a[n+1]=a[n]*Fraction(9*n+1,n*n-8*n+17) | |
maxA=max(a) | |
ans=0 | |
for n in range(N+1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
from decimal import * | |
A,B=1,1 | |
for N in range(10000): | |
A=(N+1)*A+1 | |
B=(N+1)*B | |
delta=int(math.log10(B*N))-10 | |
print(delta) | |
getcontext().prec=delta | |
print(Decimal(A)/Decimal(B)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class fenwick_tree(): | |
n=1 | |
data=[0 for i in range(n)] | |
def __init__(self,N): | |
self.n=N | |
self.data=[0 for i in range(N)] | |
def add(self,p,x): | |
assert 0<=p<self.n,"0<=p<n,p={0},n={1}".format(p,self.n) | |
p+=1 | |
while(p<=self.n): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
S=input() | |
for i in S: | |
assert 48<=ord(i)<58 | |
X=[["┏━━┓","┏┓","┏━━┓","┏━━┓","┏┓┏┓","┏━━┓","┏━━┓","┏━━┓","┏━━┓","┏━━┓"], | |
["┃┏┓┃","┃┃","┗━┓┃","┗━┓┃","┃┃┃┃","┃┏━┛","┃┏━┛","┃┏┓┃","┃┏┓┃","┃┏┓┃"], | |
["┃┃┃┃","┃┃","┏━┛┃","┏━┛┃","┃┗┛┃","┃┗━┓","┃┗━┓","┗┛┃┃","┃┗┛┃","┃┗┛┃"], | |
["┃┃┃┃","┃┃","┃┏━┛","┗━┓┃","┗━┓┃","┗━┓┃","┃┏┓┃"," ┃┃","┃┏┓┃","┗━┓┃"], | |
["┃┗┛┃","┃┃","┃┗━┓","┏━┛┃"," ┃┃","┏━┛┃","┃┗┛┃"," ┃┃","┃┗┛┃","┏━┛┃"], | |
["┗━━┛","┗┛","┗━━┛","┗━━┛"," ┗┛","┗━━┛","┗━━┛"," ┗┛","┗━━┛","┗━━┛"]] | |
ans=["" for i in range(6)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Z[sqrt(2)]での演算(和と積)を定義 | |
def add(x,y): | |
return (x[0]+y[0],x[1]+y[1]) | |
#x:=x[0]+sqrt(2)*x[1] | |
def time(x,y): | |
return (x[0]*y[0]+2*x[1]*y[1],x[0]*y[1]+x[1]*y[0]) | |
#a_n,b_nは共に | |
#a*x_n+b*y_nという形になっている | |
#ここで,x_nとy_nはZ[sqrt(2)]の元 | |
A=((1,0),(0,0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class heaptree(): | |
L=[None] | |
N=0 | |
def __init__(self): | |
self.L=[None] | |
self.N=0 | |
def debug(self): | |
return self.L | |
def heappush(self,v): | |
self.L.append(v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BITree: | |
def __init__(self, n): | |
self.size = n | |
self.tree = [0] * (n + 1) | |
def sum(self, i): | |
s = 0 | |
while i > 0: | |
s += self.tree[i] | |
i -= i & -i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RMQTree(): | |
INF=10**15 | |
N=1 | |
dat=[0 for i in range(2*N-1)] | |
def __init__(self,n): | |
while(self.N<n):self.N*=2 | |
for i in range(2*self.N-1): | |
self.dat[i]=self.INF | |
def update(k,a): | |
k+=self.N-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UnionFind(): | |
n=1 | |
par=[0] | |
rnk=[0] | |
def __init__(self,size): | |
self.n=size | |
self.par=[i for i in range(self.n)] | |
self.rnk=[0 for i in range(self.n)] | |
def find(self,vertex1): | |
if self.par[vertex1]==vertex1: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class modprime(): | |
mod=1000000007 | |
#mod=998244353 | |
num=0 | |
def __init__(self,number): | |
self.num=number%self.mod | |
def __repr__(self): | |
return str(self.num%self.mod) | |
def __str__(self): | |
return str(self.num%self.mod) |