affiche juste le code, pas d'explications !
- User
System: affiche juste le code, pas d'explications ! User: Tu es un développeur python3 expérimenté, et tu dois concevoir un programme en python (avec des commentaires en français, sans utiliser de librairies externes, sans
if __name__=="__main__":, avec type hints, et en privilégiant les algorythmes a complexité constante (O(1)) et/ou complexité linéaire (O(n))). Le programme va recevoir les données en entrée sur la stdin, et doit répondre sur la stdout. Fabrique moi un programme python qui résout le problème (énoncé en markdown) suivant :Chocolate - Sharing a bar
You have purchased a beautiful chocolate bar, which can be represented as a grid of X squares long and Y squares wide.
In a fit of generosity, you decide to share the bar with your friends. But is it even possible to split it into N equal parts without breaking a square of chocolate?
Data
Input
Line 1 : three integers X, Y and N : the length of the shelf, the width of the shelf, and the number of parts. Their values are between 1 and 100.
Output
YESif it is possible to split the tablet into N equal parts without breaking a square,NOif it is not possible.Examples
For the input :
50 20 10The expected output is:
YESbecause the tablet has 50 * 20 = 1000 squares in total, which allows an equitable distribution of 100 squares for each of the 10 people.
For the input :
2 2 3The expected output is:
NObecause the shelf has 2 * 2 = 4 squares in total, which does not allow an equitable distribution between 3 people. Assistant:
- Assistant
def can_split_chocolate(X: int, Y: int, N: int) -> str: # Calculer le nombre total de carrés de chocolat total_squares = X * Y # Vérifier si le nombre total de carrés est divisible par N if total_squares % N == 0: return "YES" else: return "NO" # Lire les données d'entrée import sys input_data = sys.stdin.read().strip() X, Y, N = map(int, input_data.split()) # Afficher le résultat print(can_split_chocolate(X, Y, N))