Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- from math import *
- samo = "aeiouAEIOU"
- spol = "BCDFGHJKLMNPQRSTVXZWY"
- def fme(a, k, n):
- b = bin(k)[2:] # list of bits
- m = len(b)
- r = 1 # result
- x = a % n
- for i in range(m - 1, -1, -1):
- if b[i] == '1':
- r = r * x % n
- x **= 2
- x %= n
- return r
- def rozklad(x):
- if x<=0:
- return 0
- i=2
- e=floor(sqrt(x))
- r=[] #używana jest tablica (lista), nie bepośrednie wypisywanie
- while i<=e:
- if x%i==0:
- r.append(i)
- x/=i
- e=floor(sqrt(x))
- else:
- i+=1
- if x>1: r.append(x)
- r = list(dict.fromkeys(r))
- return r
- def count_n(text):
- n1 = 0
- n2 = 0
- sp = 0
- for t in text:
- if t in samo:
- n1+=1
- elif t.upper() in spol:
- n2+=1
- elif t == " ":
- sp+=1
- return n1, n2, sp
- def JHA(text,p,q):
- n1,n2,sp = count_n(text)
- pot = 7*n1 - 3*n2 +sp*sp
- #print(pot)
- if(pot<0):
- b = (1/(q%p)) %p
- print(b)
- return fme(b,-1*pot,p)
- return fme(q,pot,p)
- print(JHA("AaBBB BBB cdcd",2741,137))
- p = int(input("podaj p:"))
- g = input("podaj g: ")
- k = input("podaj k: ")
- r = input("podaj r: ")
- q = sorted(rozklad(p-1))[-1]
- with open('tekst_krotki1.txt') as file:
- line = file.read()
- print('q : ',q)
- print("skrót : ", JHA(line,p,q))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement