Skip to content

Commit f31bf54

Browse files
committed
python
1 parent 45e900e commit f31bf54

26 files changed

+245
-0
lines changed

PY01004 - NGUYÊN TỐ.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from math import gcd
2+
from math import sqrt
3+
4+
def prime(n):
5+
if n < 2: return False
6+
for i in range(2,int(sqrt(n))+1):
7+
if n%i == 0: return False
8+
return True
9+
10+
test = int(input())
11+
for i in range(test):
12+
k = 0
13+
n = int(input())
14+
for i in range(n):
15+
if gcd(n,i) == 1: k=k+1
16+
if(prime(k)): print("YES")
17+
else: print("NO")

PY01005 - SỐ MAY MẮN.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
n = input()
2+
cnt = 0
3+
for i in n:
4+
if i=='4' or i == '7': cnt = cnt+1
5+
if cnt == 4 or cnt == 7: print("YES")
6+
else: print("NO")

PY01006 - SỐ MAY MẮN - 2.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def lucky(n):
2+
for i in n:
3+
if i != '4' and i != '7': return "NO"
4+
return "YES"
5+
test = int(input())
6+
for i in range(test):
7+
n = input()
8+
print(lucky(n))
9+

PY01007 - LÃI SUẤT NGÂN HÀNG.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from math import log
2+
test = int(input())
3+
for i in range(test):
4+
n,x,m = [ float(x) for x in input().split() ]
5+
print(int(log( m/n, 1 + x/100 )) + 1 )
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
s = input()
2+
print(s.upper())
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
s = input()
2+
hoa = 0
3+
thuong = 0
4+
for i in s:
5+
if i <= 'z' and i >= 'a': thuong +=1
6+
else: hoa +=1
7+
if hoa > thuong: print(s.upper())
8+
else: print(s.lower())

PY01010 - ĐẦU CUỐI.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def check(n):
2+
if(n[0]==n[-2] and n[1]==n[-1]): return "YES"
3+
return "NO"
4+
test = int(input())
5+
for i in range(test):
6+
s = input()
7+
print(check(s))
8+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from math import gcd
2+
from math import sqrt
3+
def phan_tich(x):
4+
tong = 0
5+
while x != 0:
6+
tong += x%10
7+
x = int(x/10)
8+
return tong
9+
def prime(x):
10+
if x < 2: return "NO"
11+
else:
12+
for i in range(2,int(sqrt(x))+1):
13+
if x%i == 0: return "NO"
14+
return "YES"
15+
t = int(input())
16+
for _ in range(t):
17+
x,y = [int(a) for a in input().split()]
18+
print(prime(phan_tich(gcd(x,y))))

PY01014 - CHIA HẾT CHO K.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
a,k,n = [int(x) for x in input().split()]
2+
i = 1
3+
ok = 1
4+
while k*i <=n:
5+
if k*i - a > 0 :
6+
ok = 0
7+
print(k*i - a,end = ' ')
8+
i+=1
9+
if ok: print(-1)

PY01015 - SỐ KHÔNG GIẢM.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
t = int(input())
2+
def check(s):
3+
for i in range(len(s) - 1):
4+
if s[i] > s[i+1]: return "NO"
5+
return "YES"
6+
for i in range(t):
7+
s = input()
8+
print(check(s))

0 commit comments

Comments
 (0)