upd: add some files

This commit is contained in:
2023-11-06 11:47:56 +08:00
parent 3e0ca43a03
commit 59aef02010
83 changed files with 32860 additions and 1 deletions

View File

@ -0,0 +1,2 @@
#WELCOME
#HAVE A GOOD DAY!

View File

View File

@ -0,0 +1,2 @@
#Hello, World!
print("Hello, World!")

View File

@ -0,0 +1 @@
Hello, World!

View File

@ -0,0 +1,4 @@
#Function Test
def foo():
return
foo()

View File

@ -0,0 +1,7 @@
#Function Test
def foo(a):
print(a)
i = 0
while i < 10:
foo(i)
i += 1

View File

@ -0,0 +1,10 @@
0
1
2
3
4
5
6
7
8
9

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,80 @@
#Pollard Rho
def quick_power(x , y , p) :
ret = 1
while y != 0 :
if y % 2 == 1 :
ret *= x
ret %= p
x *= x
x %= p
y //= 2
return ret
def miller_rabin(x , n) :
cnt = 0
m = n - 1
while m % 2 == 0 :
cnt += 1
m //= 2
x = quick_power(x , m , n)
if x == 1 : return True
while cnt :
cnt -= 1
if x == 1 : return False
if x == n - 1 : return True
x *= x
x %= n
return x == 1
def is_prime(x) :
if x == 2 or x == 3 or x == 5 or x == 7 or x == 11 or x == 13 or x == 17 or x == 19 or x == 23 or x == 29 or x == 31 or x == 37 : return True
if x == 1 or x % 2 == 0 : return False
i = 2
while i <= 37 :
if not miller_rabin(i , x) : return False
i += 1
return True
def gcd(x , y) :
if y == 0 : return x
return gcd(y , x % y)
def F(n , p , c) : return (n * n + c) % p
seed = 19260817
def rand() :
seed += seed * 131072
seed += seed // 32
seed += seed * 4096
seed %= 4294967296
return seed
def random(n) : return rand() % n
def iabs(x) :
if x >= 0 : return x
else : return -x
def pollard_rho(n) :
#print ("try" , n)
if n == 1 : return
if is_prime(n) :
print(n)
return
while True :
c , p = random(n - 1) + 1 , random(n - 1) + 1
q = F(p , n , c)
while p != q :
g = gcd(iabs(p - q) , n)
if g != 1 and g != n :
pollard_rho(g)
pollard_rho(n // g)
return
p , q = F(p , n , c) , F(F(q , n , c) , n , c)
pollard_rho(998244352)
print()
pollard_rho(809172)
print()
pollard_rho(151299083768042202434037960)

View File

@ -0,0 +1,48 @@
7
2
2
2
2
2
2
2
2
2
17
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
19
2
3
3
13
13
7
19
2
2
2
23
7
3
5
13
17
97
19260817
998244353

View File

@ -0,0 +1,4 @@
#Print Test
print(65536)
print(True)
print(None)

View File

@ -0,0 +1,3 @@
65536
True
None

View File

@ -0,0 +1,6 @@
#Variable Test
a = 1
a = "WELCOME!"
#a = 1
print(a)

View File

@ -0,0 +1 @@
WELCOME!

View File

@ -0,0 +1,5 @@
#Upper Case and Lower Case
a = 1
A = True
b = A
print(b)

View File

@ -0,0 +1 @@
True

View File

@ -0,0 +1,3 @@
#Simple Evaluation
print(1 + 1) #Love
print(1+1) #Hate

View File

@ -0,0 +1,2 @@
2
2

View File

@ -0,0 +1,10 @@
#Comparision Test
two = 0 + 1 * 2
three = two + 1
print(two < three)
print(two > three)
print(two <= three)
print(two >= three)
print(two == three)
print(two != three)

View File

@ -0,0 +1,6 @@
True
False
True
False
False
True

View File

@ -0,0 +1,10 @@
#String Operation Test
Hello = "Hello, "
World = "World!"
print(Hello + World)
Hello *= 3
print(Hello + "is there anybody in there?")
cmp = Hello <= World
print(cmp)
print(not cmp)

View File

@ -0,0 +1,4 @@
Hello, World!
Hello, Hello, Hello, is there anybody in there?
True
False

View File

@ -0,0 +1,9 @@
#If Statement
a = 1
b = 2
if a < b:
print(b)
# elif a > b:
# print(a)
# else:
# print("equal")

View File

@ -0,0 +1 @@
2

View File

@ -0,0 +1,5 @@
#While Statement Test
i = 0
while i < 10:
print("**********")
i += 1

View File

@ -0,0 +1,10 @@
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********