Автор | Сообщение |
|
Отправлено: 27.10.20 20:23. Заголовок: Задача №119 КЕГЭ №8
119) (А.М. Кабанов) Алексей составляет 5-буквенные слова из букв М, А, Г, И, С, Т, Р. Каждую букву можно использовать не более одного раза, при этом в слове нельзя использовать более одной гласной. Сколько различных кодов может составить Алексей? по моим подсчетом ответ 1200, но в таблице ответ 1320 А 1*5*4*3*2=120 А может быть на 5 позициях, значит 5*120=600 Тоже самое для буквы И, значит всего 1200 написал программу, ответ тоже 1200 from itertools import permutations perm = permutations('МАГИСТР', 5) n = 0 for x in list(perm): if x.count('А')==1 and x.count('И')==0 or\ x.count('И')==1 and x.count('А')==0: n += 1 print(n) Где ошибка?
|
|
|
Ответов - 8
[только новые]
|
|
|
Отправлено: 27.10.20 23:18. Заголовок: Ответ
if x.count('А')==1 and x.count('И')==0 or\ x.count('И')==1 and x.count('А')==0 or x.count('И')==0 and x.count('А')==0: Ответ: 1320.
|
|
|
|
Отправлено: 18.04.21 20:00. Заголовок: polyakovss пишет: ..
polyakovss пишет: [quote]` import itertools a=list(itertools.permutations('МАГИСТР', r=5)) count=0 for i in a: if (i.count('А')<=1 and i.count('И')==0) or (i.count('А')==0 and i.count('И')<=1): count+=1 print(i) print(count)
|
|
|
|
Отправлено: 28.10.20 14:22. Заголовок: Задача №119 КЕГЭ №8
спасибо! не правильно понял условие)
|
|
|
|
Отправлено: 19.04.22 09:19. Заголовок: Слова могут ещё без ..
Слова могут ещё без гласных быть, поэтому 1320
|
|
|
|
Отправлено: 28.10.22 16:14. Заголовок: from itertools impor..
from itertools import * k=0 for x in product('магистр', repeat=5): s= ''.join(x) if s.count('м') == 1 and s.count('г') == 1 and s.count('р') == 1 and s.count('с') == 1 and s.count('т') == 1 and (s.count('а') + s.count('и'))<=1: k += 1 print(k) в чём ошибка?
|
|
|
|
Отправлено: 28.10.22 16:14. Заголовок: from itertools impor..
from itertools import * k=0 for x in product('магистр', repeat=5): s= ''.join(x) if s.count('м') == 1 and s.count('г') == 1 and s.count('р') == 1 and s.count('с') == 1 and s.count('т') == 1 and (s.count('а') + s.count('и'))<=1: k += 1 print(k) в чём ошибка?
|
|
|
|
Отправлено: 28.10.22 16:14. Заголовок: from itertools impor..
from itertools import * k=0 for x in product('магистр', repeat=5): s= ''.join(x) if s.count('м') == 1 and s.count('г') == 1 and s.count('р') == 1 and s.count('с') == 1 and s.count('т') == 1 and (s.count('а') + s.count('и'))<=1: k += 1 print(k) в чём ошибка?
|
|
|
|
Отправлено: 28.10.22 16:14. Заголовок: from itertools impor..
from itertools import * k=0 for x in product('магистр', repeat=5): s= ''.join(x) if s.count('м') == 1 and s.count('г') == 1 and s.count('р') == 1 and s.count('с') == 1 and s.count('т') == 1 and (s.count('а') + s.count('и'))<=1: k += 1 print(k) в чём ошибка?
|
|
|
|