Skip to content

Commit

Permalink
python
Browse files Browse the repository at this point in the history
  • Loading branch information
NEETNETNET committed Jul 29, 2023
1 parent 45e900e commit f31bf54
Show file tree
Hide file tree
Showing 26 changed files with 245 additions and 0 deletions.
17 changes: 17 additions & 0 deletions PY01004 - NGUYÊN TỐ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from math import gcd
from math import sqrt

def prime(n):
if n < 2: return False
for i in range(2,int(sqrt(n))+1):
if n%i == 0: return False
return True

test = int(input())
for i in range(test):
k = 0
n = int(input())
for i in range(n):
if gcd(n,i) == 1: k=k+1
if(prime(k)): print("YES")
else: print("NO")
6 changes: 6 additions & 0 deletions PY01005 - SỐ MAY MẮN.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
n = input()
cnt = 0
for i in n:
if i=='4' or i == '7': cnt = cnt+1
if cnt == 4 or cnt == 7: print("YES")
else: print("NO")
9 changes: 9 additions & 0 deletions PY01006 - SỐ MAY MẮN - 2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def lucky(n):
for i in n:
if i != '4' and i != '7': return "NO"
return "YES"
test = int(input())
for i in range(test):
n = input()
print(lucky(n))

5 changes: 5 additions & 0 deletions PY01007 - LÃI SUẤT NGÂN HÀNG.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from math import log
test = int(input())
for i in range(test):
n,x,m = [ float(x) for x in input().split() ]
print(int(log( m/n, 1 + x/100 )) + 1 )
2 changes: 2 additions & 0 deletions PY01008 - CHUYỂN THÀNH CHỮ HOA.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
s = input()
print(s.upper())
8 changes: 8 additions & 0 deletions PY01009 - CHỮ HOA – CHỮ THƯỜNG.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
s = input()
hoa = 0
thuong = 0
for i in s:
if i <= 'z' and i >= 'a': thuong +=1
else: hoa +=1
if hoa > thuong: print(s.upper())
else: print(s.lower())
8 changes: 8 additions & 0 deletions PY01010 - ĐẦU CUỐI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def check(n):
if(n[0]==n[-2] and n[1]==n[-1]): return "YES"
return "NO"
test = int(input())
for i in range(test):
s = input()
print(check(s))

18 changes: 18 additions & 0 deletions PY01013 - ƯỚC SỐ CHUNG NGUYÊN TỐ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from math import gcd
from math import sqrt
def phan_tich(x):
tong = 0
while x != 0:
tong += x%10
x = int(x/10)
return tong
def prime(x):
if x < 2: return "NO"
else:
for i in range(2,int(sqrt(x))+1):
if x%i == 0: return "NO"
return "YES"
t = int(input())
for _ in range(t):
x,y = [int(a) for a in input().split()]
print(prime(phan_tich(gcd(x,y))))
9 changes: 9 additions & 0 deletions PY01014 - CHIA HẾT CHO K.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
a,k,n = [int(x) for x in input().split()]
i = 1
ok = 1
while k*i <=n:
if k*i - a > 0 :
ok = 0
print(k*i - a,end = ' ')
i+=1
if ok: print(-1)
8 changes: 8 additions & 0 deletions PY01015 - SỐ KHÔNG GIẢM.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
t = int(input())
def check(s):
for i in range(len(s) - 1):
if s[i] > s[i+1]: return "NO"
return "YES"
for i in range(t):
s = input()
print(check(s))
6 changes: 6 additions & 0 deletions PY01016 - GIẢI MÃ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
t = int(input())
for _ in range(t):
s = input()
for i in range(len(s)-1):
if i%2 == 0: print(s[i]*int(s[i+1]),end='')
print()
13 changes: 13 additions & 0 deletions PY01017 - MÃ HÓA 1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
t = int(input())
for _ in range(t):
s = input()
cnt = 1
for i in range(len(s)-1):
if s[i] == s[i+1]:
cnt +=1
else:
print(cnt,end='')
print(s[i],end='')
cnt = 1
print(cnt,end='')
print(s[-1])
9 changes: 9 additions & 0 deletions PY01019 - KHOẢNG CÁCH KÝ TỰ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
t = int(input())
def check(s):
a = s[::-1]
for i in range(1,len(s)):
if abs(ord(s[i])-ord(s[i-1])) != abs(ord(a[i])-ord(a[i-1])): return "NO"
return "YES"
for _ in range(t):
s = input()
print(check(s))
8 changes: 8 additions & 0 deletions PY01020 - SỐ PHÁT LỘC.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def check(s):
if len(s) < 2: return "NO"
if s[-1] == '6' and s[-2] == '8': return "YES"
return "NO"
t = int(input())
for _ in range(t):
s = input()
print(check(s))
16 changes: 16 additions & 0 deletions PY01024 - CHẴN - LẺ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
def check1(s):
tong = 0
for i in s:
tong += int(i)
if tong%10 == 0: return True
return False

def check2(s):
for i in range(len(s)-1):
if abs(int(s[i])-int(s[i+1])) !=2: return False
return True
t = int(input())
for _ in range(t):
s = input()
if check1(s) and check2(s): print("YES")
else: print("NO")
2 changes: 2 additions & 0 deletions PY01028 - TÁCH TỪ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
for i in input().split():
print(i)
7 changes: 7 additions & 0 deletions PY01029 - SỐ ĐẢO NGUYÊN TỐ CÙNG NHAU.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from math import gcd
t = int(input())
for i in range(t):
s = input()
s1 = s[::-1]
if gcd(int(s),int(s1)) == 1: print("YES")
else: print("NO")
8 changes: 8 additions & 0 deletions PY01030 - NGUYÊN TỐ CÙNG NHAU.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from math import gcd
n,k = [int(x) for x in input().split()]
cnt = 0
for i in range(10**(k-1),10**k):
if gcd(n,i) ==1:
print(i,end =' ')
cnt +=1
if cnt %10 == 0: print()
9 changes: 9 additions & 0 deletions PY01036 - TÍNH TỔNG PHÂN THỨC.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
t = int(input())
for i in range(t):
a = int(input())
s = 0
k = 1
if a % 2 == 0: k = 2
for i in range(k,a+1,2):
s += 1/i
print("{:.6f}".format(s))
9 changes: 9 additions & 0 deletions PY01038 - KIỂM TRA CHIA HẾT CHO 7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
t = int(input())
for i in range(t):
n = input()
while int(n) % 7 != 0:
n1 = str(n)[::-1]
n = int(n) + int (n1)
n = str(n)
print(n)

20 changes: 20 additions & 0 deletions PY01039 - KIỂM TRA SỐ ĐẸP.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
def check(n):
a = n[0]
b = n[1]
if a == b: return "NO"
if len(n) % 2 == 0:
for i in range(2,len(n)-1,2):
if n[i] != a: return "NO"
for i in range(3,len(n),2):
if n[i] != b: return "NO"
else:
for i in range(2,len(n),2):
if n[i] != a: return "NO"
for i in range(3,len(n)-1,2):
if n[i] != b: return "NO"
return "YES"

test = int(input())
for i in range(test):
n = input()
print(check(n))
8 changes: 8 additions & 0 deletions PY01042 - KIỂM TRA HỆ CƠ SỐ 3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def check(s):
for i in s:
if i > '3' or i < '0': return "NO"
return "YES"
test = int(input())
for i in range(test):
s = input()
print(check(s))
2 changes: 2 additions & 0 deletions PY01045 - XÂU PALINDROME.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
s = input()
print(len(s)-1)
13 changes: 13 additions & 0 deletions PY01047 - KIỂM TRA NGUYÊN TỐ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from math import sqrt
def prime(s):
if s < 2 : return False
for i in range(2,int(sqrt(s))+1):
if s % i == 0: return False
return True
t = int(input())
for i in range(t):
s = input()
a =""
a += s[-4] + s[-3] + s[-2] + s[-1]
if prime(int(a)): print("YES")
else: print("NO")
20 changes: 20 additions & 0 deletions PY01049 - CHỮ SỐ NGUYÊN TỐ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from math import sqrt
def prime(s):
if s < 2 : return False
for i in range(2,int(sqrt(s))+1):
if s % i == 0: return False
return True
def check1(s):
if prime(len(s)): return True
return False
def check2(s):
cnt = 0
for i in s:
if prime(int(i)): cnt += 1
if cnt > len(s) - cnt: return True
return False
t = int(input())
for i in range(t):
s = input()
if check1(s) and check2(s): print("YES")
else: print("NO")
5 changes: 5 additions & 0 deletions PY01053 - SỐ CHIA HẾT CHO 3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
t = int(input())
for i in range(t):
a = int(input())
if a % 3 == 0: print("YES")
else: print("NO")

0 comments on commit f31bf54

Please sign in to comment.