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

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

Codeforces Round #102 (Div.2 div.1)

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

A. Help Vasilisa the Wise 2

brute force,math

ざっくりと大意

http://rsujskf.blog32.fc2.com/blog-entry-2184.htmlを参照!!
・n=(A-1)(B-2)(C-2)をみたすn,A,B,CでABC-nの最小値と最大値を求めるらしいです。

方針のようなもの

・そうだ。パクって写経しよう。
2523459のdaidailanlanさんから。

r1,r2=map(int, raw_input().split())
c1,c2=map(int, raw_input().split())
d1,d2=map(int, raw_input().split())
#n=int(raw_input())
#l=[int(x) for x in raw_input().split()]
r=-1
for a in range(1,10):
    b=r1-a
    c=c1-a
    d=c2-r1+a
    if c+d==r2 and a+d==d1 and b+c==d2 and len(set(map(str,[a,b,c,d]))&set('123456789'))==4:
        r='{0} {1}\n{2} {3}'.format(a,b,c,d)
        break
print r