ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 11.01.2024

Просмотров: 49

Скачиваний: 1

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.
''' ????????????????

# 111-bet

# 2-misol

n=int(input())

a=[[0]*n]*n

print(a)

for i in range(0,n):

for j in range(0,n):

a[i][j]=int(input(f"{i},{j}"))

print(a)

s=0

for i in range(n):

for j in range(n):

if i==j:

s+=a[i][j]

print(i,j,a[i][j],s)

print(s)

'''

# 111-bet

# 2-misol

n=int(input())

a=[[0]*n]*n

for i in range(n):

a[i]=list(map(int,input().split()))

s=0

for i in range(n):

for j in range(n):

if i==j:

s=s+a[i][j]

print(s)

3

1 2 3

4 5 6

7 8 9

15

3

10 15 20

11 -20 30

17 31 49

39

# 111-bet

# 3-misol

n=int(input())

a=[[0]*n]*n

for i in range(n):

a[i]=list(map(int,input().split()))

count=0

for i in range(n):

for j in range(n):

if i+j>n-1 and a[j][i]==0: # i>n-j-1

count+=1

print(count)

3

1 2 3

1 5 0

10 8 0

2

# 112-bet

# 1- topshiriq

n=int(input())

a=[[0]*n]*n

for i in range(n):

a[i]=list(map(int,input().split()))

mx=a[0][0]

for i in range(n):

for j in range(n):

# mx=max(mx,a[i][j])

if a[i][j]>mx:

mx=a[i][j]

print(mx)

3

1 2 3

1 5 0

10 8 0

10

# 113-bet

# 2-misol

n=int(input())

a=[[0]*n]*n

for i in range(n):

a[i]=list(map(int,input().split()))

count=0

for i in range(n):

for j in range(n):

if a[j][i]==0:

count+=1

print(count)

4

-5 0 4 11

12 -7 0 8

-9 0 0 7

15 -8 0 0

6

# 113-bet

# 3-topshiriq

n=int(input())

a=[[0]*n]*n

for i in range(n):

a[i]=list(map(int,input().split()))

count=0

for i in range(n):

count5=0

for j in range(5):

if a[i][j]==5:

count5+=1

if count5==5:

count+=1

print(count)

'''

'''

5

3 4 5 5 3

4 4 5 5 3

5 5 5 5 5

5 5 5 5 4

3 3 3 3 3

1

5

3 4 5 5 3

4 4 5 5 3

5 5 3 5 5

5 5 5 5 4

3 3 3 3 3

0

5

3 4 5 5 3

4 4 5 5 3

5 5 5 5 5

5 5 5 5 5

3 3 3 3 3

2

# 114-115-betlar

# 1-misol

n=int(input())

a=[]

for i in range(n):

a.append([])

for j in range(n):

x=int(input())

a[i].append(x)

for i in a:

print(i)

print(a)

mx=a[0][0]

s=0

for i in range(n):

for j in range(n):

s=s+a[i][j]

mx=max(mx,a[i][j])

print(f"sum={s}")

print(f"max={mx}")

3

1

2

3

5

9

12

36

25

22

[1, 2, 3]

[5, 9, 12]

[36, 25, 22]

[[1, 2, 3], [5, 9, 12], [36, 25, 22]]

sum=115

max=36

# 116-bet

# 2-kod


from random import randint # ?????????????????????

n=int(input())

a=[[0]*n]*n

print(a)

for i in range(n):

for j in range(n):

a[i][j]=randint(1,30)

for i in a:

print(i)

print()

for i in range(n):

print(sorted(a[i]))

3

[[0, 0, 0], [0, 0, 0], [0, 0, 0]]

[7, 29, 6]

[7, 29, 6]

[7, 29, 6]

[6, 7, 29]

[6, 7, 29]

[6, 7, 29]

'''

# 117-bet

# 3-kod

n=int(input())

a=[]

for i in range(n):

a.append([])

for j in range(n):

a[i].append(int(input()))

for i in a:

print(i)

k=int(input())

a.remove(a[k])

for i in a:

print(i)

3

1

2

3

4

5

6

7

8

9

[1, 2, 3]

[4, 5, 6]

[7, 8, 9]

1

[1, 2, 3]

[7, 8, 9]

# 117-118-bet

# 4-kod 2-misol

from random import randrange

n=int(input())

a=[[0]*n]*n

for i in range(n):

for j in range(n):

a[i][j]=randrange(1,50) # псевдослучайные числа

for i in a:

print(i)

mx=0

p=0

for i in range(n):


count=0

for j in range(n):

if a[i][j]%2==1:

count+=1

if count>mx:

mx=count

p=i

a.remove(a[p])

print(p)

for i in a:

print(i)

'''

# 117-118-bet

# 4-kod 2-misol

from random import randint,randrange

n=int(input())

a=[[randint(1,50) for i in range(n)] for j in range(n)] # случайные числа

# a=[[randrange(1,50) for i in range(n)] for j in range(n)]

for i in a:

print(*i)

print()

mx=0

p=0

for i in range(n):

count=0

for j in range(n):

if a[i][j]%2==1:

count+=1

if count>mx:

mx=count

p=i

a.remove(a[p])

print(p)

for i in a:

print(*i)

4

25 50 12 4

35 16 9 31

13 5 17 30

29 21 29 15

3

25 50 12 4

35 16 9 31

13 5 17 30

# 118-bet

# jiynaqtau

# from math import inf

from random import randint,randrange

n=int(input())

a=[[randint(1,50) for i in range(n)] for j in range(n)] # случайные числа

# a=[[randrange(1,50+1) for i in range(n)] for j in range(n)]

for i in a:

print(*i)

print()

mx=a[0][0] # mx=-inf

mn=a[0][0] # mn=inf

mni=0

mxi=0

for i in range(n):

for j in range(n):

if a[i][j]
mn=a[i][j]

mni=i

if a[i][j]>mx:

mx=a[i][j]

mxi=i

print(mn,mni)

print(mx,mxi)

if mni==mxi:

a.remove(a[mni])

else:

if mni
a.remove(a[mxi])

a.remove(a[mni])

else:

a.remove(a[mni])

a.remove(a[mxi])

for i in a:

print(*i)

4

50 6 33 8

39 46 4 6

17 33 2 31

34 3 38 44

2 2

50 0

39 46 4 6

34 3 38 44

# 119-bet

# 1-topshiriq

from random import randint,randrange

n,m=map(int,input().split())

a=[[randint(1,50) for i in range(m)] for j in range(n)] # случайные числа

# a=[[randrange(1,50+1) for i in range(n)] for j in range(n)]

for i in a:

print(*i)

print()

count=0

for i in range(n):

for j in range(m):

if a[i][j]%2==0:

count+=1

print(count)

3 4

39 31 20 20

22 1 4 10

32 35 32 47

7

5 4

38 10 29 4

19 20 15 21

26 11 28 1

20 45 27 43

17 40 4 44

10

'''

# 119-bet

# 2-top

from math import inf

from random import randint,randrange

n=int(input())

a=[[randint(1,50) for i in range(n)] for j in range(n)] # случайные числа

# a=[[randrange(1,50+1) for i in range(n)] for j in range(n)]

for i in a:

print(*i)

print()

mx=-inf

p=0

for i in range(n):

s=0

for j in range(n):

s=s+a[i][j]

print(s)

if s>mx:

mx=s

p=i

a.remove(a[p])

print(p)

for i in a:

print(*i)

3

6 38 10

21 43 1

19 9 44

54

65

72

2

6 38 10

21 43 1

>>>

''''''

# 120-bet

# 1-topshiriq

from random import randint

n=int(input())

a=[[randint(1,1000) for i in range(n)] for j in range(n)]

for i in a:

print(*i)

count=0

for i in range(n):

for j in range(n):

if 10<=a[i][j]<=99:

count+=1

print(count)

5

619 57 855 240 57

807 100 147 795 535

955 988 131 522 424

162 405 292 770 425

860 705 478 99 250

3

4

428 275 399 758

579 727 607 451

916 401 117 745

956 227 976 435

0

''''''

from random import randint

n=int(input())

a=[randint(1,1000) for i in range(n)]

print(*a)

count=0

for i in range(n):

if 10<=a[i]<=99:

count+=1

print(count)

30

105 780 499 346 577 935 905 998 772 910 653 282 720 541 728 750 130 225 738 788 390 1000 643 999 878 880 493 40 893 198

1

# 120-bet 1-top 1-o'lchamli

# 120-bet

# 2-topshiriq

# 1-usul

from random import randint

n=int(input())

a=[randint(30,125) for i in range(n)]



#for i in range(n):

# a[i]=int(input())

print(*a)

count=0

for i in range(n):

if 52<=a[i]<=95:

count+=1

print(count)

for i in range(n):

if 52<=a[i]<=95:

print(i,end=' ')

10

30 62 84 49 37 116 123 100 104 47

2

1 2

'''

'''

# 120-bet

# 2-topshiriq

# 2-usul

from random import randint

n=int(input())

a=[randint(30,125) for i in range(n)]

#for i in range(n):

# a[i]=int(input())

print(*a)

count=0

b=[]

for i in range(n):

if 52<=a[i]<=95:

count+=1

b.append(i)

print(count)

print(*b)

10

87 46 116 125 71 115 107 52 91 66

5

0 4 7 8 9

'''

: # 121-bet

# 3- top

f1=open('input.txt','r')

f2=open('output.txt','w')

n=int(f1.readline())

a=list(map(int,f1.readline().split()))

f1.close()

s=0

for i in range(n):

if (i+1)%2==0 and a[i]%2==1:

s=s+a[i]

f2.write(str(s))

f2.close()

'''

# 121-bet

# 4-top

# 1-usul

from array import array

n=int(input())

a=array('i',map(int,input().split()))

for i in range(n):

d1=a[i]%1000//100

d2=a[i]%100//10

d3=a[i]%10//1

if d1==d3:

print(a[i],end=' ')

''' # 121-bet

# 4-top

# 2-usul

n=int(input())

a=input().split()

for i in a:

if i[0]==i[2]:

print(i,end=' ')

# 121-bet

# 5-top 1-usul

n,k=map(int,input().split())

a=[] # pustoy spisok

for i in range(n):

a.append(list(map(int,input().split()))) # spisokning oxiriga bir qatordan qo'shadi

s=0

for i in range(n):

for j in range(n):

if a[i][j]%10==k:

s+=a[i][j]

print(s)

'''

'''

# 121-bet

# 5-top 2-usul

n,k=map(int,input().split())

a=[[0]*n]*n # 0 lar bilan to'ldirilgan list -tizim-spisok

for i in range(n):

a[i]=list(map(int,input().split())) # spisokning qatorlaridagi 0 larni kiritilgan sonlar qatoriga almashtiradi

s=0

for i in range(n):

for j in range(n):

if a[i][j]%10==k:

s+=a[i][j]

print(s)

'''

# 121-122-bet

# 6-top

n=int(input())

a=[[0]*n]*n # 0 lar bilan to'ldirilgan list -tizim-spisok

for i in range(n):

a[i]=list(map(int,input().split())) # spisokning qatorlaridagi 0 larni kiritilgan sonlar qatoriga almashtiradi

count=0

for i in range(n):

for j in range(n):

if i==j and a[i][j]%2==1:

count+=1

print(count)

'''


# 122-bet ?????????????????????

# 7-top

n,k=map(int,input().split())

a=[[0]*n]*n

for i in range(n):

a[i]=list(map(int,input().split()))

print()

for i in a:

print(*i)

count=0

for i in range(n):

count4=0

count5=0

for j in range(n):

if a[i][j]==4:

count4+=1

if a[i][j]==5:

count5+=1

if count4+count5==k:

count+=1

print(count)

#122 bet 8 top

from array import array

n=int(input())

a=array('i',map(int,input().split()))

mn=min(a)

mx=max(a)

count=0

for i in range(n):

if a[i]==mx:

count+=1

a[i]=mn

print(count)

print(*a)

10

15 18 98 36 98 7 13 87 65 98

3

15 18 7 36 7 7 13 87 65 7

# 122-bet

# 9-topshiriq

f1=open('architect.txt','r')

f2=open('result.txt','w')

n=int(f1.readline())

a=[[0 for i in range(3)] for j in range(n)]

print(*a)

for i in range(n):

a[i]=list(map(int,f1.readline().split()))

max_s=0

s_i=0

for i in range(n):

s=a[i][0]*a[i][1] # s=a*b

v=a[i][0]*a[i][1]*a[i][2] # V=a*b*c

p=2*(a[i][0]+a[i][1]) # p=2*(a+b)

f2.write(str(s)+' '+str(v)+' '+str(p))

f2.write('\n')

if s>max_s:

max_s=s

s_i=i+1

f2.write(str(s_i))

f1.close()

f2.close()

'''

# 123-bet

# 10-topshiriq

# 1-usul

n,k=map(int,input().split())

a=list(map(int,input().split()))

print(*a)

a=sorted(a,reverse=True)


print(*a)

print(sum(a[:4]))

10 4

17 70 20 30 49 78 20 60 10 50

17 70 20 30 49 78 20 60 10 50

78 70 60 50 49 30 20 20 17 10

'''

'''

# 123-bet

# 10-topshiriq

# 2-usul

n,k=map(int,input().split())

a=list(map(int,input().split()))

print(*a)

a=sorted(a)

print(*a)

print(sum(a[-4:]))

10 4

17 70 20 30 49 78 20 60 10 50

17 70 20 30 49 78 20 60 10 50

10 17 20 20 30 49 50 60 70 78

258

'''

'''

# 123-bet

# 11-topshiriq

n=int(input())

a=list(map(int,input().split())) # a=[17 70 20 30 49 78 20 60 10 50]

for i in a[::-1]: # listni oxiridan boshlab tekshirish # i=50 i=10 ...

# remove bilan o'chirganda keyingi elementlar chapga siljiydi

for j in range(2,i):

if i%j==0:

break

else:

a.remove(i)

print(*a)

10

17 70 20 30 49 78 20 60 10 50

70 20 30 49 78 20 60 10 50

>>>

10

17 19 20 30 49 78 20 60 11 13

20 30 49 78 20 60

'''

9-cinf pygame

import pygame

pygame.init()

screen=pygame.display.set_mode([100,100])

# >>> exit() - выход

'''

'''

import pygame

pygame.init()

screen=pygame.display.set_mode([640,480])

running=True

while running==True:

for event in pygame.event.get():

print(event)

if event.type==pygame.QUIT:

running=False

pygame.quit()

'''

import pygame

pygame.init()

screen=pygame.display.set_mode([640,480])

screen.fill([255,0,0]) # ekranni bo'yaydi rgb r-red g-green b-blue

pygame.draw.circle(screen,[0,255,0],[320,240],100,5)

pygame.draw.rect(screen,[0,0,255],[340,130,390,180],0)

pygame.draw.line(screen,[100,100,100],[50,100],[50,300],1)

pygame.display.flip() # ekranni 180 gradusga buradi

running=True

while running==True:

for event in pygame.event.get():

if event.type==pygame.QUIT:

running=False

pygame.quit()

# 125-bet 1 -kod

import pygame

pygame.init()

screen=pygame.display.set_mode([100,100])

# >>> exit() - выход

'''

'''

# 125-bet 2-kod

import pygame

pygame.init()

screen=pygame.display.set_mode([640,480])

running=True

while running==True:

for event in pygame.event.get():

print(event)

if event.type==pygame.QUIT:

running=False

pygame.quit()

'''

'''

#126-bet

# 3-kod

import pygame

pygame.init()

screen=pygame.display.set_mode([640,480])

screen.fill([255,0,0]) # ekranni bo'yaydi rgb r-red g-green b-blue

pygame.draw.circle(screen,[0,255,0],[320,240],100,5)

pygame.draw.rect(screen,[0,0,255],[340,130,390,180],0)

pygame.draw.line(screen,[100,100,100],[50,100],[50,300],1)

pygame.display.flip() # ekranni 180 gradusga buradi

running=True

while running==True:

for event in pygame.event.get():

if event.type==pygame.QUIT:

running=False

pygame.quit()

pygame.draw.rect(screen,[0,0,255],[100,120,25,70],0) # x=100 y=120 eni=25 bo'yi=70

# 127-bet

# 4-rasm

import pygame

pygame.init()

screen=pygame.display.set_mode([700,500])

pygame.draw.circle(screen,[0,0,255],[225,50],25,0)

pygame.draw.circle(screen,[0,0,255],[175,75],20,0)

pygame.draw.circle(screen,[0,0,255],[125,100],15,0)

pygame.draw.rect(screen,[0,0,255],[100,125,25,75],0) # x=100 y=120 eni=25 bo'yi=70

pygame.draw.rect(screen,[0,0,255],[75,200,125,75],0)

pygame.draw.rect(screen,[0,0,255],[200,125,100,150],0)

pygame.draw.rect(screen,[0,255,255],[225,150,50,50],0)

pygame.draw.line(screen,[100,100,100],[300,250],[325,250],5)

pygame.draw.rect(screen,[0,255,255],[325,150,225,125],0)

pygame.draw.rect(screen,[0,255,255],[225,150,50,50],0)

pygame.draw.circle(screen,[0,0,255],[125,300],25,0)

pygame.draw.circle(screen,[0,0,255],[250,300],25,0)

pygame.draw.circle(screen,[0,0,255],[350,300],25,0)

pygame.draw.circle(screen,[0,0,255],[375+25,300],25,0)

pygame.draw.circle(screen,[0,0,255],[450+25,300],25,0)

pygame.draw.circle(screen,[0,0,255],[500+25,300],25,0)


pygame.display.flip() # ekranni 180 gradusga buradi

running=True

while running==True:

for event in pygame.event.get():

if event.type==pygame.QUIT:

running=False

pygame.quit()