YottaGin

Freedom is a responsible choice.

[Python] ABC006 C

2019/4/18 アルゴリズム, プログラミング

問題

C – スフィンクスのなぞなぞ

回答

import sys
# input処理を高速化する
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    
    for old in range(N):
        adult = (4*N - M - old)/2
        if adult.is_integer() and adult >= 0:
            child = N - adult - old
            if child>= 0:
                print(int(adult), old, int(child))
                break
    else:
        print(-1, -1, -1)

main()

Atcoder, Python GinO

関連記事

[Python] NLTKを使ってみる (5) Sentiment Analysis 感情分析

以下の続きです。 以下参考にしています。 Python NLTK: Twitter Sentiment Analysis Sentiment Analysis 感情分析 Sentiment analysis(also known as...

記事を読む

[Python] 2分ヒープ (2)

前回からの続きです。 Python では、heapq によりheapがモジュールとして提供されているので、普段はこちらを使います。 heapq--- ヒープキューアルゴリズム ここでは、学習のため、前回の内容に沿って、Python で heap を...

記事を読む

[Python] デコレーターについて

Python のデコレーターについて理解するための個人的なまとめです。 デコレーター 8.6. 関数定義 @f1(arg) @f2 def func(): pass は大体次と等価です。 def func(): pass func = f1(arg...

記事を読む

[Python] ABC008 A

問題 A - アルバム 回答 S, T = map(int, input().split()) nums_pics = T - S + 1 print(nums_pics)

記事を読む

[Python] Pythonの練習問題サイト(英語)

時間がある時にやるための自分用のリスト。 下に行くほど難しい感じかと。 Codingbat projecteuler codeabbey Reddit の Daily Practice Problems 意味...

記事を読む


Public Domain YottaGin No Rights Reserved.