پاسخ سوالات کوئرا

اصلاح شده

2026-07-25

عبارات و دستورات

3537 - سوال زرد

کد
"""
----input
2
----output
Woow!
"""
n = int(input())
print("W","o"*n,"w!", sep="")

ساختمان

2885 - سوال ساده

کد
"""
----input
2
----output
man khoshghlab hastam
man khoshghlab hastam
"""
n = int(input())
text = "man khoshghlab hastam\n"

print((text * n).strip())

# for i in range(n):
#     print("man khoshghlab hastam")

2636 - شطرنج حرفه‌ای

کد
"""
----input
0 2 2 2 3 7
----output
1 -1 0 0 -1 1
"""
x = input().split(" ")

print(
    1 - int(x[0]),
    1 - int(x[1]),
    2 - int(x[2]),
    2 - int(x[3]),
    2 - int(x[4]),
    8 - int(x[5])
)

615 - تاریخ تولد

کد
"""
----input
7106
----output
saal:71
maah:06
----input
7011
----output
saal:70
maah:11
----input
0012
----output
saal:00
maah:12
"""
yymm = input()

print("saal:",yymm[0:2])
print("maah:", yymm[2:4])

8838 - کمک به کاپی

کد
"""
----input
2 shoma
----output
copy of copy of shoma
"""
n_text = input()
n, text = n_text.split(" ")

print("copy of " * int(n) + text)

شرط

3429 - یخدارچی

کد
"""
----input
110
----output
Steam
----input
100
----output
Water
----input
-200
----output
Ice
"""
n = int(input())
if n < 0:
    print("Ice")
elif n > 100:
    print("Steam")
else:
    print("Water")

10162 - روز آزادی بیان در برره

کد
"""
----input
1
----output
Payin Barare
----input
74
----output
Bala Barare
"""
print("Bala Barare" if int(input()) % 2 == 0 else "Payin Barare")

280 - اعداد فیثاغورثی

کد
"""
----input
3
4
5
----output
YES
"""
a, b, c = int(input()), int(input()), int(input())

if a == 0 or b == 0 or c == 0:
    print("NO")
elif a*a+b*b==c*c or a*a+c*c==b*b or c*c+b*b==a*a:
    print("YES")
else:
    print("NO")

10230 - مشق امشب باقر

کد
"""
----input
70 60 50
----output
Yes
----input
180 0 0
----output
No
----input
150 40 10
----output
No
"""
angles = input()

a1, a2, a3 = angles.split(" ")
a1 = int(a1)
a2 = int(a2)
a3 = int(a3)

if a1 == 0 or a2 == 0 or a3 == 0:
    print("No")
elif a1 + a2 + a3 != 180:
    print("No")
else:
    print("Yes")

3406 - صدگان خسته

کد
"""
----input
123
421
----output
421 < 123
----input
123
123
----output
123 = 123
----input
201
800
----output
800 < 201
"""
x = input()
y = input()

if x[2] < y [2]:
    print(x, "<", y)
elif x[2] > y [2]:
    print(y, "<", x)
else:
    if x[1] < y [1]:
        print(x, "<", y)
    elif x[1] > y [1]:
        print(y, "<", x)
    else:
        if x[0] < y [0]:
            print(x, "<", y)
        elif x[0] > y [0]:
            print(y, "<", x)
        else:
            print(x, "=", y)

51865 - بهداشت و سلامت

کد
"""
----input
14
0
----output
20
----input
6
7
----output
6
----input
13
9
----output
4
"""
score = int(input())
days = int(input())

if days == 0:
    print(20)

elif days == 7:
    print(score)

else:
    final = score - days
    if final > 0:
        print(final)
    else:
        print(0)

10325 - همایش زندگی بهتر

کد
"""
----input
1 1
----output
Right 10 1
----input
4 15
----output
Left 7 6
"""

r, c = input().split(" ")
r = int(r)
c = int(c)
d = "Right" if c <= 10 else "Left"
a = 11 - r
b = c if c <= 10 else 21 - c

print(d, a, b)

حلقه

9774 - عدد چاپ‌کن

کد
"""
----input
50943
----output
5: 55555
0:
9: 999999999
4: 4444
3: 333
"""
digits = input()

for i in digits:
    print(i + ":", i * int(i))

17244 - شارژ موبایل

کد
"""
----input
1
----output
1
----input
3
----output
6
"""
k = int(input())

time = 0

for i in range(k):
    time += i + 1

print(time)

589 - فاکتوریل

کد
"""
----input
5
----output
120
"""
n = int(input())
n_fact = 1
for i in range(1, n+1):
    n_fact *= i

print(n_fact)

3409 - جدول ضرب گنده

کد
"""
----input
3
----output
1 2 3
2 4 6
3 6 9
"""
n = int(input())
for i in range(1, n+1):
    for j in range(1, n+1):
        print(i*j, end=" ")
    print()

3539 - تک‌رقمی

کد
"""
----input
14
----output
5
"""
digits = list(input())

while len(digits) > 1:
    sum_digits = 0
    for d in digits:
        sum_digits += int(d)
    
    digits = str(sum_digits)

# while len(digits) > 1:
#     digits = str(sum([int(d) for d in digits]))
#     digits = str(sum(list(map(int, digits)))

print(digits)

282 - کامل بودن یا نبودن

کد
"""
----input
27
----output
No
----input
6
----output
YES
"""
n = int(input())
s = 0
for i in range(1, int(n/2) + 1):
    if n % i == 0:
        s += i

print("YES" if n == s else "NO")

616 - توان دو

کد
"""
----input
95
----output
128
"""
n = int(input())

for i in range(n):
    if 2**i > n:
        print(2**i)
        break

591 - چاپ مربع

کد
"""
----input
6
----output
******
*    *
*    *
*    *
*    *
******
"""
n = int(input())

for i in range(1,n+1):
    for j in range(1, n+1):
        if i == 1 or i == n or j == 1 or j == n:
            print("*", end="")
        else:
            print(" ", end="")
    print()

618 - چاپ لوزی

کد
"""
----input
3
----output
   *
  ***
 *****
*******
 *****
  ***
   *
"""
n = int(input())

for i in range(n):
    print(" " * (n - i) + "*" * (2 * i + 1))

for i in range(n + 1):
    print(" " * i + "*" * (2 * (n - i) + 1))

3405 - چاپ برعکس

کد
"""
----input
3
4
7
4
9
0
----output
9
4
7
4
3
"""
nums = []

while True:
    num = input()
    if num == "0":
        break

    nums.append(num)

nums.reverse()

for num in nums:
    print(num)

617 - عدد خودمغلوب

کد
"""
----input
2356532
----output
YES
"""

digits = input()
digits_reverse = ""
for d in digits:
    digits_reverse = d + digits_reverse

print("YES" if digits == digits_reverse else "NO")

4065 - خر در چمن فراوونه!!

کد
"""
----input
1 1 1
----output
1
----input
3 4 5
----output
17
----input
10 3 2
----output
13
"""

a, b, l = [int(x) for x in input().split(" ")]
n = 0
time = 0

i = j = 0

while n < l:
    if i == j:
        i += 1
    else:
        j += 1

    time = i * a + j * b
    n += 1


print(time)

رشته

10231 - خُب باقر سرما خورده

کد
"""
----input
N-MOLANA1
9A-UKOK
SAYE-NTERP
G-SANAEI
RF-MOLLASADRA
----output
1
----input
N321-HAFEEZ
F3-B12I
F-BI-12
OVO-JE-FE
KASHANI 
----output
NOT FOUND!
----input
47-MOLANA
BOND-007
RF-MOLANA18
MARICA-13
13A-HAFEZLL
----output
1 3 5
"""
result = []
for i in range(1, 5 + 1):
    x = input()
    if "MOLANA" in x or "HAFEZ" in x:
        result.append(str(i))

if result == []:
    result = "NOT FOUND!"

print(' '.join(result))

10232 - باقر خسته‌ست ولی بی‌فرهنگ نه

کد
"""
----input
2 10
3 5 5
5 2 2
----output
12
----input
4 30
7 13 5
14 4 4
15 3 10
25 1 1
----output
36
"""
n, l = [int(i) for i in input().split(" ")]
time = 0
last_redlight = 0

for i in range(n):
    d, r, g = [int(i) for i in input().split(" ")]

    time +=  d - last_redlight

    if time % (r + g) < r:
        time += r - time % (r + g)
    
    last_redlight = d

time += l - last_redlight
print(time)

تابع

102250 - پیدایِش!

کد
"""
def find(num1, num2, num3):
    pass
----input
>>> find(1, 2, 3)
----output
4
----input
>>> find(1, 4, 3)
----output
2
"""
def find(num1, num2, num3):
    for i in range(1, 5):
        if i not in [num1, num2, num3]:
            return i

148640 - آزمون تستی

کد
"""
----input
1
C
4
OO#O
OOOO
#OOO
OO##
----output
3
0
-1
-1
----input
10
AABBDCABCD
1
#OOO
#OOO
O#OO
O#OO
OOO#
OO#O
#OOO
O#OO
OO#O
OOO#
----output
30
"""
def check_score(answer, response):
    abcd = {"A": 0, "B": 1, "C": 2, "D": 3}
    score = 0
    if "#" not in response:
        return 0

    for i in range(4):
        if response[i] == "#":
            if i != abcd[answer]:
                return -1
            else:
                score = 3

    return score

questions = int(input())
answers = input()
papers = int(input())


for p in range(papers):
    score = 0
    for q in range(questions):
        response = input()
        score += check_score(answers[q], response)
    
    print(score)