Add 04-03-2024
This commit is contained in:
parent
0b11755298
commit
36e6b70570
27
04-03-24/a.py
Normal file
27
04-03-24/a.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import math
|
||||||
|
|
||||||
|
def are_coprime(a, b):
|
||||||
|
return math.gcd(a, b) == 1
|
||||||
|
|
||||||
|
def find_greatest():
|
||||||
|
input()
|
||||||
|
alist = [int(a) for a in input().split()]
|
||||||
|
|
||||||
|
mapping = {}
|
||||||
|
for i in range(len(alist)):
|
||||||
|
mapping[alist[i]] = i
|
||||||
|
|
||||||
|
maxi = -1
|
||||||
|
for a in mapping:
|
||||||
|
for b in mapping:
|
||||||
|
if mapping[a]+mapping[b]+2 > maxi and are_coprime(a, b):
|
||||||
|
maxi = mapping[a]+mapping[b]+2
|
||||||
|
|
||||||
|
return maxi
|
||||||
|
|
||||||
|
def main():
|
||||||
|
nb = int(input())
|
||||||
|
for i in range(nb):
|
||||||
|
print(find_greatest())
|
||||||
|
|
||||||
|
main()
|
18
04-03-24/b.py
Normal file
18
04-03-24/b.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
def pair(n):
|
||||||
|
if n%2 == 0:
|
||||||
|
return "No"
|
||||||
|
|
||||||
|
l = (3/2)*(n+1)
|
||||||
|
|
||||||
|
res = []
|
||||||
|
for i in range(1, (n+1)//2):
|
||||||
|
res.append((i, l+i-1))
|
||||||
|
|
||||||
|
for i in range(1, (n+1)//2+n%2):
|
||||||
|
res.append((n-i+1, l-i))
|
||||||
|
|
||||||
|
return "Yes\n"+"\n".join([f"{int(a[0])} {int(a[1])}" for a in res])
|
||||||
|
|
||||||
|
|
||||||
|
for _ in range(int(input())):
|
||||||
|
print(pair(int(input())))
|
30
04-03-24/c.py
Normal file
30
04-03-24/c.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import math
|
||||||
|
|
||||||
|
def get_primes(n):
|
||||||
|
divs = []
|
||||||
|
for i in range(1, int(math.sqrt(n)+1)):
|
||||||
|
if n%i == 0:
|
||||||
|
divs.append((i, n//i))
|
||||||
|
divs.append((n//i, i))
|
||||||
|
|
||||||
|
return divs
|
||||||
|
|
||||||
|
def main():
|
||||||
|
[a, b, c, d] = [int(a) for a in input().split()]
|
||||||
|
|
||||||
|
if c*d < 2*a*b:
|
||||||
|
return "-1 -1"
|
||||||
|
|
||||||
|
primes = get_primes(a*b)
|
||||||
|
|
||||||
|
for i, j in primes:
|
||||||
|
for alpha in range(1, c//i+1):
|
||||||
|
for beta in range(1, d//j+1):
|
||||||
|
#print(i*alpha, j*beta)
|
||||||
|
if (i*alpha > a and j*beta > b) and (i*alpha <= c and j*beta <= d):
|
||||||
|
return f"{i*alpha} {j*beta}"
|
||||||
|
|
||||||
|
return "-1 -1"
|
||||||
|
|
||||||
|
for _ in range(int(input())):
|
||||||
|
print(main())
|
BIN
04-03-24/sujet.pdf
Normal file
BIN
04-03-24/sujet.pdf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user