君はまるで砂漠に咲く、一輪の花。

僕はその花に引き寄せられる蝶。

Codeforces Testing Round #2

はい。
http://codeforces.com/contest/125

A. Measuring Lengths in Baden

math

ざっくりと大意

・1インチは3センチ。変換の時に端数2センチなら繰り上げ。1センチは切り捨て。
・1フィートは12インチ。切り上げ、切り捨てせずに保存してフィート数とインチ数を出力。

方針のようなもの

・その通りに計算させる。

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
n=int(raw_input())
f=n/3
if n%3==2: f+=1
i=f/12
print i,f%12

B. Simple XML

implementation

ざっくりと大意

・一行に書かれたタグを改行とインデントして整形

方針のようなもの

・入れ子で変則な閉じ方してなければテキトーにリストに入れて順に処理してなんとかなるかな?

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
s=0
n=map(str,(raw_input().split('>')))
for i in range(len(n)-1):
    if n[i][1]!='/':
        print '  '*s+n[i]+'>'
        s+=1
    else:
        s-=1
        print '  '*s+n[i]+'>'

変則な閉じ方をしてるものはなかったぽい。問題文読んでないのでそれが保証されているのかどうか知りませんが。。。(e.g.変則な閉じ方:\\\\)

今回の回答よりも平時から用意しているであろうテンプレが面白そうだったのがあり。814885のyukimさん。

#! /usr/bin/env python
# -*- coding: utf-8 -*-

def main():
    tags = filter(lambda x: x[0] == "<", getline().split(">"))
    tags = map(lambda x: x + ">", tags)

    depth = 0

    for t in tags:
        if t[1] == "/":
            depth -= 1
        print ("  " * depth) + t
        if t[1] != "/":
            depth += 1

    return 0

## -------------------------------------------
## TEMPLATE

from sys import stdin
from sys import setrecursionlimit
from copy import deepcopy
from math import sqrt
from itertools import permutations
from itertools import combinations

def getline():
    return stdin.readline()

def getLineAs(tp):
    return map(tp, getline().split())

def array(n, init = 0):
    return [deepcopy(init) for i in range(n)]

def count_if(lst, pred):
    ret = 0
    for i in lst:
        if pred(i): ret = ret + 1
    return ret

def toSepStr(lst):
    if len(lst):
        return "".join([str(item) + " " for item in lst])[:-1]
    else:
        return ""

if __name__ == "__main__":
    setrecursionlimit(1024 * 1024)
    main()