algorithm/problem solving

acmicpc.net 1357, 1252, 1212, 1316, 1302, 1356

qkqhxla1 2016. 7. 15. 16:18

파이썬은 사기다.


https://www.acmicpc.net/problem/1357

a,b = raw_input().split()
print int(str(int(a[::-1])+int(b[::-1]))[::-1])

https://www.acmicpc.net/problem/1252

a,b = map(lambda x:int(x,2),raw_input().split())
print bin(a+b)[2:]

https://www.acmicpc.net/problem/1212

print bin(int(raw_input(),8))[2:]
# -*- encoding: cp949 -*-
word = [raw_input() for i in range(int(raw_input()))]
count = 0
for i in range(len(word)):
    w_list = []; flag = True
    for j in range(len(word[i])-1):
        if word[i][j] != word[i][j+1]:
            if word[i][j+1] not in w_list:
                w_list.append(word[i][j])
            else:
                flag = False
                break
    if flag: count += 1
print count

https://www.acmicpc.net/problem/1316

book = [raw_input() for i in range(int(raw_input()))]
book_dict = {}
for i in range(len(book)):
    if book[i] not in book_dict:
        book_dict[book[i]] = 1
    else:
        book_dict[book[i]] += 1
print sorted(book_dict.iteritems(), key=lambda x:(-x[1],x[0]))[0][0]

https://www.acmicpc.net/problem/1356

# -*- encoding: cp949 -*-
def gob(gob_list):
    return reduce(lambda x, y: x*y, gob_list)

n = raw_input()
flag = True
for i in range(1,len(n)):
    if gob(map(int,n[:i]))==gob(map(int,n[i:])):
        flag = False
        print 'YES'
        break
if flag: print 'NO'