-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45e900e
commit f31bf54
Showing
26 changed files
with
245 additions
and
0 deletions.
There are no files selected for viewing
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
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") |
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
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") |
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
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)) | ||
|
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
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 ) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
s = input() | ||
print(s.upper()) |
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
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()) |
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
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)) | ||
|
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
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)))) |
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
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) |
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
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)) |
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
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() |
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
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]) |
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
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)) |
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
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)) |
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
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") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
for i in input().split(): | ||
print(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
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") |
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
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() |
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
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)) |
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
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) | ||
|
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
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)) |
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
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)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
s = input() | ||
print(len(s)-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
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") |
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
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") |
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
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") |