Skip to content

Instantly share code, notes, and snippets.

View modos's full-sized avatar
🫥
Working from home

Mohammed Hossein Mazandaranian modos

🫥
Working from home
View GitHub Profile
@modos
modos / main.py
Created August 29, 2025 08:55
تابع تواندار
from decimal import Decimal, getcontext
getcontext().prec = 50
def myPow(base: Decimal, exp: int) -> Decimal:
if exp == 0:
return Decimal(1)
half = myPow(base, exp // 2)
if exp % 2 == 0:
return half * half
@modos
modos / main.py
Created August 22, 2025 00:03
سینما سازمانی
import sys
data = sys.stdin.read().strip().split()
n, k = map(int, data[:2])
a = list(map(int, data[2:2+n]))
w = [1 + x for x in a]
w.sort()
cnt = 0
@modos
modos / main.py
Created August 21, 2025 10:43
بی‌عملگر
s = input().strip()
a, b, c = map(int, s.split('?'))
def apply(op, x, y):
return x + y if op == '+' else x * y
best = float('-inf')
for op1 in ['+', '*']:
for op2 in ['+', '*']:
best = max(best,
@modos
modos / main.py
Created August 1, 2025 11:46
دیوارکشی
a, b = map(int, input().split())
print(a % b)
@modos
modos / main.py
Created July 25, 2025 09:03
دیباگ شایسته
n = int(input())
if n == 1:
print("q")
else:
print("q" + "a" * (n - 1))
@modos
modos / main.py
Created July 18, 2025 01:17
رشته‌ی خوب و رشته‌ی بد
s = input().strip()
t = input().strip()
n = int(input())
def is_valid(res):
return s in res and t not in res
if len(s) > n:
print(-1)
exit()
@modos
modos / main.py
Created July 11, 2025 09:36
برنده والیبال
t = int(input())
for _ in range(t):
n = int(input())
s = input().strip()
count_C = 0
count_Q = 0
for ch in s:
@modos
modos / hello.sh
Created June 30, 2025 14:39
سلام DevOps
#!/bin/bash
echo "Hello DevOps!"
@modos
modos / main.py
Created June 22, 2025 02:33
Parquet (2020)
def find_dimensions(R, B):
total = R + B
for L in range(3, int(total ** 0.5) + 2):
if total % L == 0:
W = total // L
if (L - 2) * (W - 2) == B:
return max(L, W), min(L, W)
return None
R, B = map(int, input().split())
@modos
modos / main.py
Created June 15, 2025 09:54
ریاضیات و مکافات - فصل اول
def count_square_pairs(n):
count = 0
for x in range(1, int(n**0.5) + 1):
if n % x == 0:
y = n // x
if x < y and (x + y) % 2 == 0:
count += 1
return count
t = int(input())