s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s319880412
p01128
u598551137
1514371101
Python
Python3
py
Runtime Error
0
0
710
for i in range(int(input())): xa, ya, xb, yb = map(int, input().split(' ')) n = int(input()) ip = [] for j in range(n): xs, ys, xt, yt, o, l = map(int, input().split(' ')) d = (xb - xa) * (yt - ys) - (yb - ya) * (xt - xs) if d == 0: continue t0 = ((yt - ys) * (xs - xa) - (xt - xs) * (ys - ya)) / d t1 = ((yb - ya) * (xs - xa) - (xb - xa) * (ys - ya)) / d if (t0 >= 0 and t0 <= 1) and (t1 >= 0 and t1 <= 1): ip.append((t0, o == l)) count = 0 if len(ip) > 0 ip.sort(key=lambda x: x[0]) for j in range(len(ip) - 1): if ip[i][1] != ip[i + 1][1]: count += 1 print(count)
s429009128
p01128
u598551137
1514378954
Python
Python3
py
Runtime Error
0
0
707
for i in range(int(input())): xa, ya, xb, yb = map(int, input().split(' ')) n = int(input()) ip = [] for j in range(n): xs, ys, xt, yt, o, l = map(int, input().split(' ')) d = (xb - xa) * (yt - ys) - (yb - ya) * (xt - xs) if d == 0: continue t0 = ((yt - ys) * (xs - xa) - (xt - xs) * (ys - ya)) / d t1 = ((yb - ya) * (xs - xa) - (xb - xa) * (ys - ya)) / d if (t0 > 0 and t0 < 1) and (t1 > 0 and t1 < 1): ip.append((t0, o == l)) count = 0 if len(ip) > 0: ip.sort(key=lambda x: x[0]) for j in range(len(ip) - 1): if ip[j][1] != ip[j + 1][1]: count += 1 print(count)
s007181053
p01130
u633068244
1424701888
Python
Python
py
Runtime Error
19920
4648
552
inf = 10**10 while 1: n,m,s,g1,g2 = map(int,raw_input().split()) if n == 0: break s,g1,g2 = s-1,g1-1,g2-1 G = [[inf]*n for i in xrange(n)] for loop in xrange(m): b1,b2,c = map(int,raw_input().split()) G[b1-1][b2-1] = c for k in xrange(n): for i in xrange(n): for j in xrange(n): G[i][j] = min(G[i][j], G[i][k]+G[k][j]) ans = inf for i in xrange(n): ans = min(ans, G[s][i]+G[i][g1]+G[i][g2], G[s][i]+G[i][g1]+G[g1][g2], G[s][i]+G[i][g2]+G[g2][g1]) print ans
s136274975
p01130
u797673668
1461151762
Python
Python3
py
Runtime Error
0
0
1564
from heapq import heapify, heappop, heappush from operator import add while True: n, m, s, g1, g2 = map(int, input().split()) s -= 1 g1 -= 1 g2 -= 1 if not n: break pipes = [set() for _ in range(n)] for _ in range(m): b1, b2, c = map(int, input().split()) b1 -= 1 b2 -= 1 pipes[b1].add((c, b2)) pipes[b2].add((c, b1)) dists = [[None] * n for _ in range(2)] for i in (0, 1): g = (g1, g2)[i] dist = dists[i] dist[g] = 0 queue = list(pipes[g]) heapify(queue) while queue: total_cost, base = heappop(queue) if dist[base] is not None: continue dist[base] = total_cost for next_cost, next_base in pipes[base]: if dist[next_base] is None: heappush(queue, (total_cost + next_cost, next_base)) dists = list(map(add, *dists)) current_best = dists[s] queue = list(pipes[s]) heapify(queue) visited = {s} while queue: total_cost, base = heappop(queue) if base in visited: continue visited.add(base) current_best = min(current_best, total_cost + dists[base]) for next_cost, next_base in pipes[base]: if next_base not in visited: next_whole_cost = total_cost + next_cost + dists[next_base] if current_best > next_whole_cost: heappush(queue, (total_cost + next_cost, next_base)) print(current_best)
s973515961
p01131
u352394527
1531255687
Python
Python3
py
Runtime Error
0
0
667
#include <iostream> #include <string> #include <vector> using namespace std; int main(void){ int n, i, cnt; string str, ans; char init; vector<string> mp{"", ".,!? ","abc","def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"}; cin >> n; while(n--){ cin >> str; ans = ""; i = 0; while(i < str.length()){ while(str[i] == '0'){ i++; } if(i >= str.length()){ break; } init = str[i]; cnt = 0; while(i < str.length() and str[i] == init){ i++; cnt++; } ans += mp[init - '0'][(cnt - 1) % mp[init - '0'].length()]; } cout << ans << endl; } return 0; }
s161856983
p01131
u489876484
1556126420
Python
Python3
py
Runtime Error
0
0
467
N = int(input()) d = [] d.append([]) d.append([".",",","!","?"]) d.append(["a","b","c"]) d.append(["d","e","f"]) d.append(["g","h","i"]) d.append(["j","k","l"]) d.append(["m","n","o"]) d.append(["p","q","r","s"]) d.append(["t","u","v"]) d.append(["w","x","y","z"]) for _ in range(N): nn = input() output = "" b = 0 c = 0 for n in nn: n = int(n) if n == 0: output += d[b][c] c = 0 b = n
s909570350
p01131
u489876484
1556126621
Python
Python3
py
Runtime Error
0
0
480
N = int(input()) d = [] d.append([]) d.append([".",",","!","?"]) d.append(["a","b","c"]) d.append(["d","e","f"]) d.append(["g","h","i"]) d.append(["j","k","l"]) d.append(["m","n","o"]) d.append(["p","q","r","s"]) d.append(["t","u","v"]) d.append(["w","x","y","z"]) for _ in range(N): nn = input() output = "" b = 0 c = 0 for n in nn: n = int(n) if n == 0: output += d[b][c] c = 0 c += 1 print(output)
s286972724
p01131
u338932851
1450245749
Python
Python
py
Runtime Error
0
0
787
d = {1:{1:'.',2:',',3:'!',4:'?',5:' '}, 2:{1:'a',2:'b',3:'c'}, 3:{1:'d',2:'e',3:'f'}, 4:{1:'g',2:'h',3:'i'}, 5:{1:'j',2:'k',3:'l'}, 6:{1:'m',2:'n',3:'o'}, 7:{1:'p',2:'q',3:'r',4:'s'}, 8:{1:'t',2:'u',3:'v'}, 9:{1:'w',2:'x',3:'y',4:'z'} } n = int(raw_input()) for i in range(n): mes = raw_input() mes = mes.split("0") mes=filter(lambda x:len(x)>0,mes) #print mes l=[] for e in mes: l.append([e[0], len(e)]) res="" for e in l: i=int(e[0]) if(i==1): if e[1]>5:x=e[1]%5 else:x=e[1] elif(i==7 or i==9): if e[1]>4:x=e[1]%4 else:x=e[1] else: if e[1]>3:x=e[1]%3 else:x=e[1] res=res+d[i][x] print res
s809852332
p01131
u338932851
1450245939
Python
Python
py
Runtime Error
0
0
776
d = {1:{1:'.',2:',',3:'!',4:'?',5:' '}, 2:{1:'a',2:'b',3:'c'}, 3:{1:'d',2:'e',3:'f'}, 4:{1:'g',2:'h',3:'i'}, 5:{1:'j',2:'k',3:'l'}, 6:{1:'m',2:'n',3:'o'}, 7:{1:'p',2:'q',3:'r',4:'s'}, 8:{1:'t',2:'u',3:'v'}, 9:{1:'w',2:'x',3:'y',4:'z'} } n = int(raw_input()) for i in range(n): mes = raw_input() mes = mes.split("0") mes=filter(lambda x:len(x)>0,mes) l=[] for e in mes: l.append([e[0], len(e)]) res="" for e in l: i=int(e[0]) if(i==1): if e[1]>5:x=e[1]%5 else:x=e[1] elif(i==7 or i==9): if e[1]>4:x=e[1]%4 else:x=e[1] else: if e[1]>3:x=e[1]%3 else:x=e[1] res=res+d[i][x] print res
s611136627
p01131
u166860661
1480857482
Python
Python
py
Runtime Error
0
0
615
#coding: utf-8 import sys def keitai(n1,n2): li1 = ['.', ',', '!', '?'] li2 = ['a','b','c'] li3 = ['d','e','f'] li4 = ['g','h','i'] li5 = ['j','k','l'] li6 = ['m','n','o'] li7 = ['p','q','r','s'] li8 = ['t','u','v'] li9 = ['w','x','y','z'] li = [li1,li2,li3,li4,li5,li6,li7,li8,li9] lis = li[n1 - 1] n2 = n2 % len(li) a = lis[n2 - 1] return a for line in sys.stdin: a = str(line) num = 0 for i in len(a): if int(a[i]) == 0: print keitai(b,num), else: num = num + 1 b = int(a[i]) print ''
s290713083
p01131
u166860661
1480857707
Python
Python
py
Runtime Error
0
0
691
#coding: utf-8 import sys def keitai(n1,n2): li1 = ['.', ',', '!', '?'] li2 = ['a','b','c'] li3 = ['d','e','f'] li4 = ['g','h','i'] li5 = ['j','k','l'] li6 = ['m','n','o'] li7 = ['p','q','r','s'] li8 = ['t','u','v'] li9 = ['w','x','y','z'] li = [li1,li2,li3,li4,li5,li6,li7,li8,li9] lis = li[n1 - 1] n2 = n2 % len(li) a = lis[n2 - 1] return a for line in sys.stdin: a = str(line) num = 0 for i in len(a): if int(a[i]) == 0: if i = len(a) - 1: print keitai(b,num) else: print keitai(b,num), else: num = num + 1 b = int(a[i])
s683647073
p01131
u166860661
1480858200
Python
Python
py
Runtime Error
0
0
678
#coding: utf-8 import sys def keitai(n1,n2): li1 = ['.', ',', '!', '?',' '] li2 = ['a','b','c'] li3 = ['d','e','f'] li4 = ['g','h','i'] li5 = ['j','k','l'] li6 = ['m','n','o'] li7 = ['p','q','r','s'] li8 = ['t','u','v'] li9 = ['w','x','y','z'] li = [li1,li2,li3,li4,li5,li6,li7,li8,li9] lis = li[n1 - 1] n2 = n2 % len(lis) a = lis[n2 - 1] return a for line in sys.stdin: a = str(line) num = 0 string = '' for i in range(len(a)): if int(a[i]) == 0: string = string + keitai(b,num) num = 0 else: num = num + 1 b = int(a[i]) print string
s674091895
p01131
u166860661
1480858404
Python
Python
py
Runtime Error
0
0
686
#coding: utf-8 n = raw_input() def keitai(n1,n2): li1 = ['.', ',', '!', '?',' '] li2 = ['a','b','c'] li3 = ['d','e','f'] li4 = ['g','h','i'] li5 = ['j','k','l'] li6 = ['m','n','o'] li7 = ['p','q','r','s'] li8 = ['t','u','v'] li9 = ['w','x','y','z'] li = [li1,li2,li3,li4,li5,li6,li7,li8,li9] lis = li[n1 - 1] n2 = n2 % len(lis) a = lis[n2 - 1] return a for k in range(n): a = str(raw_input()) num = 0 string = '' for i in range(len(a)): if int(a[i]) == 0: string = string + keitai(b,num) num = 0 else: num = num + 1 b = int(a[i]) print string
s830770755
p01131
u399892098
1485944983
Python
Python
py
Runtime Error
0
0
430
import re di = {1:".,!? ",2:"abc",3:"def",4:"ghi" ,5:"jkl",6:"mno",7:"pqrs",8:"tuv",9:"wxyz"} while True: str = "" line = raw_input() if line.endswith("0") is False: break list = re.split("0+",line) for line in list: if line is not '': index = (len(line)-1)%len(di[int(line[:1])]) first_num = int(line[:1]) str += di[first_num][index] print str
s833173897
p01131
u399892098
1485945059
Python
Python
py
Runtime Error
0
0
370
import re di = {1:".,!? ",2:"abc",3:"def",4:"ghi" ,5:"jkl",6:"mno",7:"pqrs",8:"tuv",9:"wxyz"} while True: str = "" line = raw_input() if line.endswith("0") is False: break list = re.split("0+",line) for line in list: if line is not '': str += di[int(line[:1])][(len(line)-1)%len(di[int(line[:1])])] print str
s551801670
p01131
u399892098
1485945855
Python
Python
py
Runtime Error
0
0
453
import re di = {1:".,!? ",2:"abc",3:"def",4:"ghi" ,5:"jkl",6:"mno",7:"pqrs",8:"tuv",9:"wxyz"} while True: str = "" line = raw_input() if line.endswith("0") is False: break list = re.split("0+",line) for line in list: if line is not '' and len(set(line)) < 2: first_num = int(line[:1]) str += di[first_num][(len(line)-1)%len(di[int(line[:1])])] if str is not "": print str
s006266887
p01131
u399892098
1491801738
Python
Python
py
Runtime Error
0
0
518
import sys di = {1:".,!? ",2 :"abc",3:"def",4:"ghi",5:"jkl",6:"mno",7:"pqrs",8:"tuv",9:"wxyz"} while True: a = raw_input() count = 0 le = 999 fl = False for letter in a: if(letter == "0"): if(le == 999): pass else: sys.stdout.write(di[le][(count-1)%len(di[le])]) count = 0 le = 999 fl = True else: le = int(letter) count += 1 if(fl): print ""
s491653430
p01131
u399892098
1491801762
Python
Python
py
Runtime Error
0
0
518
import sys di = {1:".,!? ",2 :"abc",3:"def",4:"ghi",5:"jkl",6:"mno",7:"pqrs",8:"tuv",9:"wxyz"} while True: a = raw_input() count = 0 le = 999 fl = False for letter in a: if(letter == "0"): if(le == 999): pass else: sys.stdout.write(di[le][(count-1)%len(di[le])]) count = 0 le = 999 fl = True else: le = int(letter) count += 1 if(fl): print ""
s398774135
p01131
u301729341
1500132872
Python
Python3
py
Runtime Error
0
0
818
moji_lis = [[".",",","!","?"," "],["a","b","c"],["d","e","f"],["g","h","i"],["j","k","l"],["m","n","o"],["p","q","r","s"],["t","u","v"],["w","x","y","z"]] n = int(input()) for i in range(n): N_lis = list(input()) N_lis = list(map(int,N_lis)) a_0 = N_lis[0] n_num = 1 moji = "" for j in range(1,len(N_lis)): a_1 = N_lis[j] if a_0 == a_1: n_num += 1 else: if a_0 == 1: moji += moji_lis[0][(n_num - 1) % 5] elif a_0 == 6 or a_0 == 8: moji += moji_lis[a_0 - 1][(n_num - 1) % 4] elif a_0 != 0: moji += moji_lis[a_0 - 1][(n_num - 1) % 3] a_0 = a_1 if a_1 == 0: n_num = 1 print(moji)
s502701673
p01131
u011621222
1528895413
Python
Python3
py
Runtime Error
0
0
384
K = '.,!? ' A = 'abc' D = 'def' G = 'ghi' J = 'jkl' M = 'mno' P = 'pqrs' T = 'tuv' W = 'wxyz' L = ['', K, A, D, G, J, M, P, T, W] while 1: S = [] n = input() if not '0' in n: print('') else: n = n.split('0') for ns in n: if ns == '': continue i = len(ns) % len(L[int(ns[0])]) S += [[L[int(ns[0])], i-1]] for s in S: print(s[0][s[1]], end='') print('')
s325151004
p01131
u136916346
1529988561
Python
Python3
py
Runtime Error
0
0
642
from itertools import cycle as c n=int(input()) for _ in range(n): tt=input() l=[] t="" for (i,j) in enumerate(tt): ct=int(j) if ct==0 or i==0: if i!=0: l.extend([t]) t="" kk=[c([".",",","!","?"," "]), c(["a","b","c"]), c(["d","e","f"]), c(["g","h","i"]), c(["j","k","l"]), c(["m","n","o"]), c(["p","q","r","s"]), c(["t","u","v"]), c(["w","x","y","z"])] if ct!=0 : t=kk[ct-1].next() print("".join(l))
s730481314
p01131
u107750881
1379326974
Python
Python
py
Runtime Error
0
0
505
#include <iostream> using namespace std; string kei[] = {".,!? ","abc","defd","ghi", "jkl","mno","pqrs","tuv","wxyz",}; int main(){ string str; int n; cin >> n; while(n--){ cin >> str; int cnt = 0; for(int i = 0 ; i < str.size()-1 ; i++ ){ if(str[i] == str[i+1]&&str[i] != '0')cnt++; if(str[i] == '0' && str[i+1] == '0')continue; if(str[i+1] == '0'){ cout << kei[(str[i]-'0')-1][cnt%(kei[(str[i]-'0')-1].size())]; cnt = 0; } } cout << endl; } }
s784601001
p01131
u093607836
1382868961
Python
Python
py
Runtime Error
0
0
375
from sys import stdin from itertools import groupby a = ['_','.,!? ','abc','def','ghi','jkl','mno','pqrs','tuv','wxyz'] for i in input(): b = [[i for i in j] for i,j in groupby(raw_input())] c = [] d = '' for i in b: index = int(i[0]) s = a[index][(len(i))%len(a[index])-1] if s == '_': d = d + ''.join(c) c = [] else: c.append(s) if d != '': print d
s710384915
p01132
u633068244
1421851427
Python
Python
py
Runtime Error
19930
4284
1071
coins = [10,50,100,500] while 1: cost = int(raw_input()) if cost == 0: break c = map(int,raw_input().split()) num = sum(c) mn = num ans = [0,0,0,0] for i in range(c[0]+1): for j in range(c[1]+1): for k in range(c[2]+1): for l in range(c[3]+1): pay = 10*i+50*j+100*k+500*l change = pay-cost if change < 0: continue tmp = [0,0,0,0] for m in range(3,-1,-1): while change-coins[m] >= 0: change -= coins[m] tmp[m] += 1 for c1,c2 in zip([i,j,k,l],tmp): if c1 > 0 and c2 > 0: break else: if num - (i+j+k+l) + sum(tmp) < mn: mn = num - (i+j+k+l) + sum(tmp) ans = [i,j,k,l] for ci,ki in zip(coins,ans): if ki == 0: continue print ci,ki print
s944992060
p01132
u316268279
1421908564
Python
Python3
py
Runtime Error
19920
6912
734
#!/usr/bin/env python # -*- coding: utf-8 -*- from itertools import product coins = [10,50,100,500] def coin_count(num): count = 0 for coin in sorted(coins,reverse = True): count += num // coin num -= (num // coin)*coin return count while True: price = int(input()) if price == 0: break dp = [-1 for i in range(20*660)] dp[0] = 0 has = map(lambda x:list(range(int(x)+1)),input().split(" ")) ans = (10**8,()) for t in product(*has): tmp = price - sum([coins[i] * t[i] for i in range(4)]) if tmp <= 0: ans = min(ans,(coin_count(-1 * tmp),t)) for i in range(4): if ans[1][i] != 0: print(coins[i],ans[1][i]) print()
s193604022
p01132
u120360464
1423122573
Python
Python
py
Runtime Error
19930
4280
1113
#! /usr/bin/python # -*- coding: utf-8 -*- def change(val): v500 = val/500 v100 = (val-v500)/100 v50 = (val%100)/50 v10 = (val%50)/10 return v10+v50+v100+v500 n = int(raw_input()) cnt = 0 while n!=0: if cnt > 0: print (c10, c50, c100, c500) = map(int, raw_input().split()) Min = 1000000 a10=0 a50=0 a100=0 a500=0 for i1 in range(c10+1): for i2 in range(c50+1): for i3 in range(c100+1): for i4 in range(c500+1): Sumc = i1+i2+i3+i4 Sumv = i1*10+i2*50+i3*100+i4*500 if Sumv >= n: Re = change(Sumv-n) if Min > Re-Sumc: Min = Re-Sumc a10 = i1 a50 = i2 a100 = i3 a500 = i4 if a10 > 0: print 10, a10 if a50 > 0: print 50, a50 if a100 > 0: print 100, a100 if a500 > 0: print 500, a500 n = int(raw_input()) cnt += 1
s635377116
p01132
u408260374
1432029536
Python
Python3
py
Runtime Error
19930
6760
1155
def makeCahnge(c): money = c ret = [] for i in [500, 100, 50, 10]: ret.append(money // i) money %= i return ret[::-1] ansOut = [] while True: price = int(input()) if price == 0: break c10, c50, c100, c500 = map(int, input().split()) ans = 20*4+1 anspay = [0, 0, 0, 0] for i10 in range(c10+1): for i50 in range(c50+1): for i100 in range(c100+1): for i500 in range(c500+1): payment = sum(i*c for i, c in zip([i10, i50, i100, i500], [10, 50, 100, 500])) if payment >= price: if sum(i-c+p for i, c, p in zip([i10, i50, i100, i500], [c10, c50, c100, c500], makeCahnge(payment - price))) < ans: ans = sum(i-c+p for i, c, p in zip([i10, i50, i100, i500], [c10, c50, c100, c500], makeCahnge(payment - price))) anspay = [i10, i50, i100, i500] out = [] for i, c in zip(anspay, [10, 50, 100, 500]): if i > 0: out.append('{} {}'.format(c, i)) ansOut.append('\n'.join(out)) print('\n\n'.join(ansOut))
s978028985
p01132
u584779197
1495959929
Python
Python
py
Runtime Error
0
0
3220
while True: import copy pay = int(input()) if pay == 0: break else: num = input() l = num.split(' ') m10 = int(l[0]) m50 = int(l[1]) m100 = int(l[2]) m500 = int(l[3]) m10s = int(copy.deepcopy(l[0])) m50s = int(copy.deepcopy(l[1])) m100s = int(copy.deepcopy(l[2])) m500s = int(copy.deepcopy(l[3])) num10 = 0 num50 = 0 num100 = 0 num500 = 0 while pay>=500: if m10 >=50: pay -= 500 m10 -= 50 elif m50 >= 10: pay -= 500 m50 -= 10 elif m100 >= 5: pay -= 500 m100 -= 5 else: pay -= 500 m500 -= 1 while pay >= 100: if m10 >= 10: pay -= 100 m10 -= 10 elif m50 >= 2: pay -= 100 m50 -= 2 elif m100 >= 1: pay -= 100 m100 -= 1 else: pay -= 500 m500 -= 1 while pay >= 50: if m10 >= 5: pay -= 50 m10 -= 5 elif m50 >= 1: pay -= 50 m50 -= 1 elif m100 >= 1: pay -= 100 m100 -= 1 else: pay -= 500 m500 -= 1 while pay >= 10: if m10 >= 1: pay -= 10 m10 -= 1 elif m50 >= 1: pay -= 50 elif m100 >= 1: pay -= 100 m100 -= 1 else: pay -= 500 m500 -= 1 m10b = 0 m50b = 0 m100b = 0 m500b = 0 if pay < 0: pay = -pay if pay < 50: m10 -= (50-pay)/10 elif pay < 100: m10 -= (100-pay)/10 elif pay < 500: m100 -= (500-pay)//100 n = (500-pay)%100 m50 -= (100-n)//50 m = n%50 m10 -= (50-m)/10 num10 = m10s - m10 num50 = m50s - m50 num100 = m100s - m100 num500 = m500s - m500 m10 += m10b m100 += m100b m50 += m50b m500 += m500b while m10 >= 50: m10 -= 50 num10 += 50 while m10 >= 10: m10 -= 10 num10 += 10 while m10 >= 5: m10 -= 5 num10 += 5 while m50 >= 10: m50 -= 10 num50 += 10 while m50 >= 2: m50 -= 2 num50 += 2 while m100 >= 5: m100 -= 5 num100 += 5 if num10: print(10,int(num10) if num50: print(50,int(num50)) if num100: print(100,int(num100)) if num500: print(500,int(num500)) print()
s756294212
p01132
u584779197
1495961033
Python
Python
py
Runtime Error
0
0
3233
while True: import copy pay = int(input()) if pay == 0: break else: num = input() l = num.split(' ') m10 = int(l[0]) m50 = int(l[1]) m100 = int(l[2]) m500 = int(l[3]) m10s = int(copy.deepcopy(l[0])) m50s = int(copy.deepcopy(l[1])) m100s = int(copy.deepcopy(l[2])) m500s = int(copy.deepcopy(l[3])) num10 = 0 num50 = 0 num100 = 0 num500 = 0 while pay>=500: if m10 >=50: pay -= 500 m10 -= 50 elif m50 >= 10: pay -= 500 m50 -= 10 elif m100 >= 5: pay -= 500 m100 -= 5 else: pay -= 500 m500 -= 1 while pay >= 100: if m10 >= 10: pay -= 100 m10 -= 10 elif m50 >= 2: pay -= 100 m50 -= 2 elif m100 >= 1: pay -= 100 m100 -= 1 else: pay -= 500 m500 -= 1 while pay >= 50: if m10 >= 5: pay -= 50 m10 -= 5 elif m50 >= 1: pay -= 50 m50 -= 1 elif m100 >= 1: pay -= 100 m100 -= 1 else: pay -= 500 m500 -= 1 while pay >= 10: if m10 >= 1: pay -= 10 m10 -= 1 elif m50 >= 1: pay -= 50 elif m100 >= 1: pay -= 100 m100 -= 1 else: pay -= 500 m500 -= 1 m10b = 0 m50b = 0 m100b = 0 m500b = 0 if pay < 0: pay = -pay if pay < 50: m10 -= (50-pay)/10 elif pay < 100: m10 -= (100-pay)/10 elif pay < 500: m100 -= (500-pay)//100 n = (500-pay)%100 m50 -= (100-n)//50 m = n%50 m10 -= (50-m)/10 num10 = m10s - m10 num50 = m50s - m50 num100 = m100s - m100 num500 = m500s - m500 m10 += m10b m100 += m100b m50 += m50b m500 += m500b while m10 >= 50: m10 -= 50 num10 += 50 while m10 >= 10: m10 -= 10 num10 += 10 while m10 >= 5: m10 -= 5 num10 += 5 while m50 >= 10: m50 -= 10 num50 += 10 while m50 >= 2: m50 -= 2 num50 += 2 while m100 >= 5: m100 -= 5 num100 += 5 if num10!=0: print(10,int(num10)) if num50!=0: print(50,int(num50)) if num100!=0: print(100,int(num100)) if num500!=0: print(500,int(num500)) print()
s442485526
p01132
u584779197
1495961350
Python
Python
py
Runtime Error
0
0
3272
while True: import copy pay = int(input()) if pay == 0: break else: num = input() l = num.split(' ') m10 = int(l[0]) m50 = int(l[1]) m100 = int(l[2]) m500 = int(l[3]) m10s = int(copy.deepcopy(l[0])) m50s = int(copy.deepcopy(l[1])) m100s = int(copy.deepcopy(l[2])) m500s = int(copy.deepcopy(l[3])) num10 = 0 num50 = 0 num100 = 0 num500 = 0 while pay>=500: if m10 >=50: pay -= 500 m10 -= 50 elif m50 >= 10: pay -= 500 m50 -= 10 elif m100 >= 5: pay -= 500 m100 -= 5 else: pay -= 500 m500 -= 1 while pay >= 100: if m10 >= 10: pay -= 100 m10 -= 10 elif m50 >= 2: pay -= 100 m50 -= 2 elif m100 >= 1: pay -= 100 m100 -= 1 else: pay -= 500 m500 -= 1 while pay >= 50: if m10 >= 5: pay -= 50 m10 -= 5 elif m50 >= 1: pay -= 50 m50 -= 1 elif m100 >= 1: pay -= 100 m100 -= 1 else: pay -= 500 m500 -= 1 while pay >= 10: if m10 >= 1: pay -= 10 m10 -= 1 elif m50 >= 1: pay -= 50 elif m100 >= 1: pay -= 100 m100 -= 1 else: pay -= 500 m500 -= 1 m10b = 0 m50b = 0 m100b = 0 m500b = 0 if pay < 0: pay = -pay if 0 < pay and pay < 50: m10 -= (50-pay)/10 elif 50 < pay and pay < 100: m10 -= (100-pay)/10 elif 100 < pay and pay < 500: m100 -= (500-pay)//100 n = (500-pay)%100 m50 -= (100-n)//50 m = n%50 m10 -= (50-m)/10 num10 = m10s - m10 num50 = m50s - m50 num100 = m100s - m100 num500 = m500s - m500 m10 += m10b m100 += m100b m50 += m50b m500 += m500b while m10 >= 50: m10 -= 50 num10 += 50 while m10 >= 10: m10 -= 10 num10 += 10 while m10 >= 5: m10 -= 5 num10 += 5 while m50 >= 10: m50 -= 10 num50 += 10 while m50 >= 2: m50 -= 2 num50 += 2 while m100 >= 5: m100 -= 5 num100 += 5 if num10!=0: print(10,int(num10)) if num50!=0: print(50,int(num50)) if num100!=0: print(100,int(num100)) if num500!=0: print(500,int(num500)) print()
s106061830
p01132
u635391238
1508244029
Python
Python3
py
Runtime Error
0
0
1348
def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1. oturi = coin_values[0]*coin_nums[0]\ +coin_values[1]*coin_nums[1]\ +coin_values[2]*coin_nums[2]\ +coin_values[3]*coin_nums[3]\ -fee use_coins = [0] * len(coin_value) no_use_coins = [0]*len(coin_value) # 2. for i in range(len(coin_value)-1, -1, -1): print(coin_value[i]) import pdb;pdb.set_trace() no_use_coins[i] = int(oturi / coin_value[i]) oturi = oturi - (coin_value[i] * no_use_coins[i]) #3. for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(coin_value[i],' ',use_coins[i]) if __name__ == "__main__": total_fee = int(input('total_fee:')) coins = input('total_coins:') coins = coins.split(' ') #10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_value=[10, 50, 100, 500] back_oturigation(total_fee, coin_value, coins)
s014185569
p01132
u635391238
1508244093
Python
Python3
py
Runtime Error
0
0
1348
def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1. oturi = coin_values[0]*coin_nums[0]\ +coin_values[1]*coin_nums[1]\ +coin_values[2]*coin_nums[2]\ +coin_values[3]*coin_nums[3]\ -fee use_coins = [0] * len(coin_value) no_use_coins = [0]*len(coin_value) # 2. for i in range(len(coin_value)-1, -1, -1): print(coin_value[i]) import pdb;pdb.set_trace() no_use_coins[i] = int(oturi / coin_value[i]) oturi = oturi - (coin_value[i] * no_use_coins[i]) #3. for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(coin_value[i],' ',use_coins[i]) if __name__ == "__main__": total_fee = int(input('total_fee:')) coins = input('total_coins:') coins = coins.split(' ') #10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_value=[10, 50, 100, 500] back_oturigation(total_fee, coin_value, coins)
s664492834
p01132
u635391238
1508310227
Python
Python3
py
Runtime Error
0
0
1511
def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1. oturi = coin_values[0]*coin_nums[0]\ +coin_values[1]*coin_nums[1]\ +coin_values[2]*coin_nums[2]\ +coin_values[3]*coin_nums[3]\ -fee use_coins = [0] * len(coin_values) no_use_coins = [0]*len(coin_values) # 2. for i in range(len(coin_values)-1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) #3. result = "" for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) result = result+str(coin_values[i]) + ' ' + str(use_coins[i])+'\n' return result if __name__ == "__main__": #check_testcase() total_fee = int(input('total_fee:')) while(True): if total_fee == 0:break coins = input('total_coins:') coins = coins.split(' ') #10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values=[10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s245870654
p01132
u635391238
1508310302
Python
Python3
py
Runtime Error
0
0
1511
def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1. oturi = coin_values[0]*coin_nums[0]\ +coin_values[1]*coin_nums[1]\ +coin_values[2]*coin_nums[2]\ +coin_values[3]*coin_nums[3]\ -fee use_coins = [0] * len(coin_values) no_use_coins = [0]*len(coin_values) # 2. for i in range(len(coin_values)-1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) #3. result = "" for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) result = result+str(coin_values[i]) + ' ' + str(use_coins[i])+'\n' #return result if __name__ == "__main__": #check_testcase() total_fee = int(input('total_fee:')) while(True): if total_fee == 0:break coins = input('total_coins:') coins = coins.split(' ') #10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values=[10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s361409631
p01132
u635391238
1508310341
Python
Python3
py
Runtime Error
0
0
1487
def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1. oturi = coin_values[0]*coin_nums[0]\ +coin_values[1]*coin_nums[1]\ +coin_values[2]*coin_nums[2]\ +coin_values[3]*coin_nums[3]\ -fee use_coins = [0] * len(coin_values) no_use_coins = [0]*len(coin_values) # 2. for i in range(len(coin_values)-1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) #3. result = "" for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) result = result+str(coin_values[i]) + ' ' + str(use_coins[i])+'\n' #return result if __name__ == "__main__": total_fee = int(input('total_fee:')) while(True): if total_fee == 0:break coins = input('total_coins:') coins = coins.split(' ') #10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values=[10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s140430022
p01132
u635391238
1508310395
Python
Python3
py
Runtime Error
0
0
1511
def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1. oturi = coin_values[0]*coin_nums[0]\ +coin_values[1]*coin_nums[1]\ +coin_values[2]*coin_nums[2]\ +coin_values[3]*coin_nums[3]\ -fee use_coins = [0] * len(coin_values) no_use_coins = [0]*len(coin_values) # 2. for i in range(len(coin_values)-1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) #3. result = "" for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) result = result+str(coin_values[i]) + ' ' + str(use_coins[i])+'\n' #return result if __name__ == "__main__": #check_testcase() total_fee = int(input('total_fee:')) while(True): if total_fee == 0:break coins = input('total_coins:') coins = coins.split(' ') #10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values=[10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s657940146
p01132
u635391238
1508310520
Python
Python3
py
Runtime Error
0
0
1552
def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1. oturi = coin_values[0] * coin_nums[0] \ + coin_values[1] * coin_nums[1] \ + coin_values[2] * coin_nums[2] \ + coin_values[3] * coin_nums[3] \ - fee use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) # 2. for i in range(len(coin_values) - 1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) # 3. result = '' for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) result = result + str(coin_values[i]) + ' ' + str(use_coins[i]) + '\n' # return result if __name__ == "__main__": # check_testcase() total_fee = int(input('total_fee:')) while (True): if total_fee == 0: break coins = input('total_coins:') coins = coins.split(' ') # 10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s875133597
p01132
u635391238
1508310643
Python
Python3
py
Runtime Error
0
0
1554
def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1. oturi = coin_values[0] * coin_nums[0] \ + coin_values[1] * coin_nums[1] \ + coin_values[2] * coin_nums[2] \ + coin_values[3] * coin_nums[3] \ - fee use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) # 2. for i in range(len(coin_values) - 1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) # 3. result = '' for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) # result = result + str(coin_values[i]) + ' ' + str(use_coins[i]) + '\n' # return result if __name__ == "__main__": # check_testcase() total_fee = int(input('total_fee:')) while (True): if total_fee == 0: break coins = input('total_coins:') coins = coins.split(' ') # 10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s396102916
p01132
u635391238
1508310926
Python
Python3
py
Runtime Error
0
0
1506
def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1. oturi = coin_values[0] * coin_nums[0] \ + coin_values[1] * coin_nums[1] \ + coin_values[2] * coin_nums[2] \ + coin_values[3] * coin_nums[3] \ - fee use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) # 2. for i in range(len(coin_values) - 1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) # 3. result = '' for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) # result = result + str(coin_values[i]) + ' ' + str(use_coins[i]) + '\n' # return result if __name__ == "__main__": total_fee = int(input('total_fee:')) while (total_fee != 0): coins = input('total_coins:') coins = coins.split(' ') # 10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s577825371
p01132
u635391238
1508310992
Python
Python3
py
Runtime Error
0
0
1043
def back_oturigation(fee, coin_values, coin_nums): oturi = coin_values[0] * coin_nums[0] \ + coin_values[1] * coin_nums[1] \ + coin_values[2] * coin_nums[2] \ + coin_values[3] * coin_nums[3] \ - fee use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) for i in range(len(coin_values) - 1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) if __name__ == "__main__": total_fee = int(input('total_fee:')) while (total_fee != 0): coins = input('total_coins:') coins = coins.split(' ') # 10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s592842545
p01132
u635391238
1508311189
Python
Python3
py
Runtime Error
0
0
1379
def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1. oturi = coin_values[0] * coin_nums[0] \ + coin_values[1] * coin_nums[1] \ + coin_values[2] * coin_nums[2] \ + coin_values[3] * coin_nums[3] \ - fee use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) # 2. for i in range(len(coin_values) - 1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) # 3. for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) if __name__ == "__main__": total_fee = int(input('total_fee:')) while (total_fee != 0): coins = input('total_coins:') coins = coins.split(' ') # 10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s112136158
p01132
u635391238
1508311228
Python
Python3
py
Runtime Error
0
0
1418
# http://www.deqnotes.net/acmicpc/p0006/ def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1. oturi = coin_values[0] * coin_nums[0] \ + coin_values[1] * coin_nums[1] \ + coin_values[2] * coin_nums[2] \ + coin_values[3] * coin_nums[3] \ - fee use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) # 2. for i in range(len(coin_values) - 1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) # 3. for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) if __name__ == "__main__": total_fee = int(input('total_fee:')) while (total_fee != 0): coins = input('total_coins:') coins = coins.split(' ') # 10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s556799400
p01132
u635391238
1508311316
Python
Python3
py
Runtime Error
0
0
1369
def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1. oturi = coin_values[0] * coin_nums[0] \ + coin_values[1] * coin_nums[1] \ + coin_values[2] * coin_nums[2] \ + coin_values[3] * coin_nums[3] \ - fee use_coins = [0] * len(coin_value) no_use_coins = [0] * len(coin_value) # 2. for i in range(len(coin_value) - 1, -1, -1): no_use_coins[i] = int(oturi / coin_value[i]) oturi = oturi - (coin_value[i] * no_use_coins[i]) # 3. for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_value[i]) + ' ' + str(use_coins[i])) if __name__ == "__main__": total_fee = int(input('total_fee:')) while (total_fee != 0): coins = input('total_coins:') coins = coins.split(' ') # 10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_value = [10, 50, 100, 500] back_oturigation(total_fee, coin_value, coins)
s260560939
p01132
u635391238
1508311371
Python
Python3
py
Runtime Error
0
0
2416
# http://www.deqnotes.net/acmicpc/p0006/ import re # def check_testcase(): # with open('./2007-input.txt') as f: # input_testcase = f.read() # with open('./2007-output.txt') as f: # pre_output_testcase = f.read() # input_testcase = input_testcase.splitlines() # pre_output_testcase = re.findall('([0-9]*\s[0-9]*)(?=\n)', pre_output_testcase) # # output_testcase = [''] * int(len(input_testcase) / 2) # cnt = 0 # for x in pre_output_testcase: # if x == '\n': # cnt += 1 # else: # output_testcase[cnt] = output_testcase[cnt] + x + '\n' # # for i in range(0, len(output_testcase), 1): # fee = int(input_testcase[i * 2]) # coin = [int(x) for x in input_testcase[i * 2 + 1].split(' ')] # coin_value = [10, 50, 100, 500] # # result = back_oturigation(fee, coin_value, coin) # # if result == output_testcase[i]: # print("PASS") # else: # import ipdb; # ipdb.set_trace() def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1. oturi = coin_values[0] * coin_nums[0] \ + coin_values[1] * coin_nums[1] \ + coin_values[2] * coin_nums[2] \ + coin_values[3] * coin_nums[3] \ - fee use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) # 2. for i in range(len(coin_values) - 1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) # 3. for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) if __name__ == "__main__": total_fee = int(input('total_fee:')) while (total_fee != 0): coins = input('total_coins:') coins = coins.split(' ') # 10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s360000389
p01132
u635391238
1508311522
Python
Python3
py
Runtime Error
0
0
2430
# http://www.deqnotes.net/acmicpc/p0006/ import re # def check_testcase(): # with open('./2007-input.txt') as f: # input_testcase = f.read() # with open('./2007-output.txt') as f: # pre_output_testcase = f.read() # input_testcase = input_testcase.splitlines() # pre_output_testcase = re.findall('([0-9]*\s[0-9]*)(?=\n)', pre_output_testcase) # # output_testcase = [''] * int(len(input_testcase) / 2) # cnt = 0 # for x in pre_output_testcase: # if x == '\n': # cnt += 1 # else: # output_testcase[cnt] = output_testcase[cnt] + x + '\n' # # for i in range(0, len(output_testcase), 1): # fee = int(input_testcase[i * 2]) # coin = [int(x) for x in input_testcase[i * 2 + 1].split(' ')] # coin_value = [10, 50, 100, 500] # # result = back_oturigation(fee, coin_value, coin) # # if result == output_testcase[i]: # print("PASS") # else: # import ipdb; # ipdb.set_trace() def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1. oturi = coin_values[0] * coin_nums[0] \ + coin_values[1] * coin_nums[1] \ + coin_values[2] * coin_nums[2] \ + coin_values[3] * coin_nums[3] \ - fee use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) # 2. for i in range(len(coin_values) - 1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) # 3. for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) if __name__ == "__main__": total_fee = int(input('total_fee:')) while (total_fee != 0): coins = input('total_coins:') coins = coins.split(' ') # 10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins) print('')
s446348084
p01132
u635391238
1508754690
Python
Python3
py
Runtime Error
0
0
2431
# http://www.deqnotes.net/acmicpc/p0006/ import re import numpy as np def check_testcase(): with open('./2007-input.txt') as f: input_testcase = f.read() with open('./2007-output.txt') as f: pre_output_testcase = f.read() input_testcase = input_testcase.splitlines() pre_output_testcase = re.findall('([0-9]*\s[0-9]*)(?=\n)', pre_output_testcase) output_testcase = [''] * int(len(input_testcase) / 2) cnt = 0 for x in pre_output_testcase: if x == '\n': cnt += 1 else: output_testcase[cnt] = output_testcase[cnt] + x + '\n' for i in range(0, len(output_testcase), 1): fee = int(input_testcase[i * 2]) coin = [int(x) for x in input_testcase[i * 2 + 1].split(' ')] coin_value = [10, 50, 100, 500] result = back_oturigation(fee, coin_value, coin) if result == output_testcase[i]: print("PASS") else: import ipdb; ipdb.set_trace() def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1 coin_values=np.array(coin_values) coin_nums=np.array(coin_nums) all = np.dot(coin_values, coin_nums) oturi = all - fee use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) # 2. for i in reversed(range(0,len(coin_values))): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) # 3. for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) if __name__ == "__main__": first = True while (True): total_fee = int(input('')) if total_fee == 0: break if first: first = False else: print('') coins = input('') coins = coins.split(' ') # 10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s372579575
p01132
u635391238
1508754727
Python
Python3
py
Runtime Error
0
0
1496
# http://www.deqnotes.net/acmicpc/p0006/ import re import numpy as np def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1 coin_values=np.array(coin_values) coin_nums=np.array(coin_nums) all = np.dot(coin_values, coin_nums) oturi = all - fee use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) # 2. for i in reversed(range(0,len(coin_values))): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) # 3. for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) if __name__ == "__main__": first = True while (True): total_fee = int(input('')) if total_fee == 0: break if first: first = False else: print('') coins = input('') coins = coins.split(' ') # 10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s990556919
p01132
u635391238
1508754791
Python
Python3
py
Runtime Error
0
0
1499
# http://www.deqnotes.net/acmicpc/p0006/ import re import numpy def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1 coin_values=numpy.array(coin_values) coin_nums=numpy.array(coin_nums) all = numpy.dot(coin_values, coin_nums) oturi = all - fee use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) # 2. for i in reversed(range(0,len(coin_values))): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) # 3. for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) if __name__ == "__main__": first = True while (True): total_fee = int(input('')) if total_fee == 0: break if first: first = False else: print('') coins = input('') coins = coins.split(' ') # 10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s493237403
p01132
u635391238
1508754827
Python
Python3
py
Runtime Error
0
0
1113
import numpy def back_oturigation(fee, coin_values, coin_nums): coin_values=numpy.array(coin_values) coin_nums=numpy.array(coin_nums) all = numpy.dot(coin_values, coin_nums) oturi = all - fee use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) for i in reversed(range(0,len(coin_values))): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) if __name__ == "__main__": first = True while (True): total_fee = int(input('')) if total_fee == 0: break if first: first = False else: print('') coins = input('') coins = coins.split(' ') # 10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s682310689
p01132
u635391238
1508754962
Python
Python3
py
Runtime Error
0
0
2436
# http://www.deqnotes.net/acmicpc/p0006/ import re import numpy as np def check_testcase(): with open('./2007-input.txt') as f: input_testcase = f.read() with open('./2007-output.txt') as f: pre_output_testcase = f.read() input_testcase = input_testcase.splitlines() pre_output_testcase = re.findall('([0-9]*\s[0-9]*)(?=\n)', pre_output_testcase) output_testcase = [''] * int(len(input_testcase) / 2) cnt = 0 for x in pre_output_testcase: if x == '\n': cnt += 1 else: output_testcase[cnt] = output_testcase[cnt] + x + '\n' for i in range(0, len(output_testcase), 1): fee = int(input_testcase[i * 2]) coin = [int(x) for x in input_testcase[i * 2 + 1].split(' ')] coin_value = [10, 50, 100, 500] result = back_oturigation(fee, coin_value, coin) if result == output_testcase[i]: print("PASS") else: import ipdb; ipdb.set_trace() def back_oturigation(fee, coin_values, coin_nums): """ 1. ????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ???????????§?????????????????????-> ?°????????????????????¶??????????????????? 3. 2????????????????????°????????????????????????????????????????????? """ # 1 coin_values=np.array(coin_values) coin_nums=np.array(coin_nums) all = np.dot(coin_values, coin_nums) oturi = int(all - fee) use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) # 2. for i in reversed(range(0,len(coin_values))): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) # 3. for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) if __name__ == "__main__": first = True while (True): total_fee = int(input('')) if total_fee == 0: break if first: first = False else: print('') coins = input('') coins = coins.split(' ') # 10, 50, 100, 500????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s482273225
p01132
u635391238
1508755276
Python
Python3
py
Runtime Error
0
0
1518
import numpy as np def back_oturigation(fee, coin_values, coin_nums): """ 1. ?????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ????????????§?????????????????????-> ??°?????????????????????¶??????????????????? 3. 2?????????????????????°????????????????????????????????????????????? """ # 1. oturi = coin_values[0] * coin_nums[0] \ + coin_values[1] * coin_nums[1] \ + coin_values[2] * coin_nums[2] \ + coin_values[3] * coin_nums[3] \ - fee use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) # 2. for i in range(len(coin_values) - 1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) # 3. for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) if __name__ == "__main__": first = True while (True): total_fee = int(input('')) if total_fee == 0: break if first: first = False else: print('') coins = input('') coins = coins.split(' ') # 10, 50, 100, 500?????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s557000076
p01132
u635391238
1508755313
Python
Python3
py
Runtime Error
0
0
1440
def back_oturigation(fee, coin_values, coin_nums): """ 1. ?????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ????????????§?????????????????????-> ??°?????????????????????¶??????????????????? 3. 2?????????????????????°????????????????????????????????????????????? """ # 1. coin_values=np.array(coin_values) coin_nums=np.array(coin_nums) all = np.dot(coin_values, coin_nums) oturi = int(all - fee) use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) # 2. for i in range(len(coin_values) - 1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) # 3. for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) if __name__ == "__main__": first = True while (True): total_fee = int(input('')) if total_fee == 0: break if first: first = False else: print('') coins = input('') coins = coins.split(' ') # 10, 50, 100, 500?????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s907624025
p01132
u635391238
1508755580
Python
Python3
py
Runtime Error
0
0
1453
import numpy def back_oturigation(fee, coin_values, coin_nums): """ 1. ?????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ????????????§?????????????????????-> ??°?????????????????????¶??????????????????? 3. 2?????????????????????°????????????????????????????????????????????? """ # 1. coin_values=np.array(coin_values) coin_nums=np.array(coin_nums) all = np.dot(coin_values, coin_nums) oturi = int(all - fee) use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) # 2. for i in range(len(coin_values) - 1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) # 3. for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) if __name__ == "__main__": first = True while (True): total_fee = int(input('')) if total_fee == 0: break if first: first = False else: print('') coins = input('') coins = coins.split(' ') # 10, 50, 100, 500?????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s140788834
p01132
u635391238
1508755667
Python
Python3
py
Runtime Error
0
0
1452
import math def back_oturigation(fee, coin_values, coin_nums): """ 1. ?????????????????????????????????£?????????????????? 2. 1???????????????????????????????????????????????????????????? ????????????§?????????????????????-> ??°?????????????????????¶??????????????????? 3. 2?????????????????????°????????????????????????????????????????????? """ # 1. coin_values=np.array(coin_values) coin_nums=np.array(coin_nums) all = np.dot(coin_values, coin_nums) oturi = int(all - fee) use_coins = [0] * len(coin_values) no_use_coins = [0] * len(coin_values) # 2. for i in range(len(coin_values) - 1, -1, -1): no_use_coins[i] = int(oturi / coin_values[i]) oturi = oturi - (coin_values[i] * no_use_coins[i]) # 3. for i in range(0, len(use_coins), 1): use_coins[i] = coin_nums[i] - no_use_coins[i] if use_coins[i] > 0: print(str(coin_values[i]) + ' ' + str(use_coins[i])) if __name__ == "__main__": first = True while (True): total_fee = int(input('')) if total_fee == 0: break if first: first = False else: print('') coins = input('') coins = coins.split(' ') # 10, 50, 100, 500?????????§???????????? coins = [int(coin) for coin in coins] coin_values = [10, 50, 100, 500] back_oturigation(total_fee, coin_values, coins)
s513010095
p01132
u506554532
1513152421
Python
Python3
py
Runtime Error
0
0
862
def calc(c1,c2,c3,c4): return c1*10 + c2*50 + c3*100 + c4*500 def coindiff(p,c1,c2,c3,c4): n = c1+c2+c3+c4 over = calc(c1,c2,c3,c4) - p n -= (over%50) // 10 n -= (over%100) // 50 n -= (over%500) // 100 n -= over // 500 return n while True: N = int(input()) if N == 0: break c1,c2,c3,c4 = map(int,input().split()) s1 = (N//10) % 5 maxdiff = -9999999 ans = None for n1 in range(s1,c1+1,5): for n2 in range(c2+1): for n3 in range(c3+1): rem = (N - n1*10 - n2*50 - n3*100) n4 = max(0, (rem-1)//500 + 1) d = coindiff(N,n1,n2,n3,n4) if d > maxdiff: maxdiff = d ans = {10:n1,50:n2,100:n3,500:n4} for k,v in sorted(ans.items()): print('{0} {1}'.format(k, v)) print('')
s895985264
p01132
u506554532
1513152658
Python
Python3
py
Runtime Error
0
0
890
def calc(c1,c2,c3,c4): return c1*10 + c2*50 + c3*100 + c4*500 def coindiff(p,c1,c2,c3,c4): n = c1+c2+c3+c4 over = calc(c1,c2,c3,c4) - p n -= (over%50) // 10 n -= (over%100) // 50 n -= (over%500) // 100 n -= over // 500 return n while True: N = int(input()) if N == 0: break c1,c2,c3,c4 = map(int,input().split()) s1 = (N//10) % 5 maxdiff = -9999999 ans = None for n1 in range(s1,c1+1,5): for n2 in range(c2+1): for n3 in range(c3+1): rem = (N - n1*10 - n2*50 - n3*100) n4 = max(0, (rem-1)//500 + 1) d = coindiff(N,n1,n2,n3,n4) if d > maxdiff: maxdiff = d ans = {10:n1,50:n2,100:n3,500:n4} for k,v in sorted(ans.items()): if v == 0: continue print('{0} {1}'.format(k, v)) print('')
s889655088
p01132
u506554532
1513153185
Python
Python3
py
Runtime Error
0
0
890
def calc(c1,c2,c3,c4): return c1*10 + c2*50 + c3*100 + c4*500 def coindiff(p,c1,c2,c3,c4): n = c1+c2+c3+c4 over = calc(c1,c2,c3,c4) - p n -= (over%50) // 10 n -= (over%100) // 50 n -= (over%500) // 100 n -= over // 500 return n while True: N = int(input()) if N == 0: break c1,c2,c3,c4 = map(int,input().split()) s1 = (N//10) % 5 maxdiff = -9999999 ans = None for n1 in range(s1,c1+1,5): for n2 in range(c2+1): for n3 in range(c3+1): rem = (N - n1*10 - n2*50 - n3*100) n4 = max(0, (rem-1)//500 + 1) d = coindiff(N,n1,n2,n3,n4) if d > maxdiff: maxdiff = d ans = {10:n1,50:n2,100:n3,500:n4} for k,v in sorted(ans.items()): if v == 0: continue print('{0} {1}'.format(k, v)) print('')
s847084635
p01132
u506554532
1513153382
Python
Python3
py
Runtime Error
0
0
953
def calc(c1,c2,c3,c4): return c1*10 + c2*50 + c3*100 + c4*500 def coindiff(p,c1,c2,c3,c4): n = c1+c2+c3+c4 over = calc(c1,c2,c3,c4) - p n -= (over%50) // 10 n -= (over%100) // 50 n -= (over%500) // 100 n -= over // 500 return n first = True while True: N = int(input()) if N == 0: break if first: first = False else: print('') c1,c2,c3,c4 = map(int,input().split()) s1 = (N//10) % 5 maxdiff = -9999999 ans = None for n1 in range(s1,c1+1,5): for n2 in range(c2+1): for n3 in range(c3+1): rem = (N - n1*10 - n2*50 - n3*100) n4 = max(0, (rem-1)//500 + 1) d = coindiff(N,n1,n2,n3,n4) if d > maxdiff: maxdiff = d ans = {10:n1,50:n2,100:n3,500:n4} for k,v in sorted(ans.items()): if v == 0: continue print('{0} {1}'.format(k, v))
s608871701
p01132
u506554532
1513159428
Python
Python3
py
Runtime Error
0
0
1023
def calc(c1,c2,c3,c4): return c1*10 + c2*50 + c3*100 + c4*500 def coindiff(p,c1,c2,c3,c4): n = c1+c2+c3+c4 over = calc(c1,c2,c3,c4) - p n -= (over%50) // 10 n -= (over%100) // 50 n -= (over%500) // 100 n -= over // 500 return n first = True while True: N = int(input()) if N == 0: break if first: first = False else: print('') c1,c2,c3,c4 = map(int,input().split()) s1 = (N//10) % 5 maxdiff = -9999999 ans = None for n1 in range(s1,c1+1,5): for n2 in range(c2+1): rem2 = N - n1*10 - n2*50 s3 = ((rem2-1)//100 + 1) % 5 for n3 in range(s3,c3+1,5): rem3 = rem2 - n3*100 n4 = max(0, (rem3-1)//500 + 1) d = coindiff(N,n1,n2,n3,n4) if d > maxdiff: maxdiff = d ans = {10:n1,50:n2,100:n3,500:n4} for k,v in sorted(ans.items()): if v == 0: continue print('{0} {1}'.format(k, v))
s200765639
p01132
u506554532
1513176758
Python
Python3
py
Runtime Error
0
0
1023
def calc(c1,c2,c3,c4): return c1*10 + c2*50 + c3*100 + c4*500 def coindiff(p,c1,c2,c3,c4): n = c1+c2+c3+c4 over = calc(c1,c2,c3,c4) - p n -= (over%50) // 10 n -= (over%100) // 50 n -= (over%500) // 100 n -= over // 500 return n first = True while True: N = int(input()) if N == 0: break if first: first = False else: print('') c1,c2,c3,c4 = map(int,input().split()) s1 = (N//10) % 5 maxdiff = -9999999 ans = None for n1 in range(s1,c1+1,5): for n2 in range(c2+1): rem2 = N - n1*10 - n2*50 s3 = ((rem2-1)//100 + 1) % 5 for n3 in range(s3,c3+1,5): rem3 = rem2 - n3*100 n4 = max(0, (rem3-1)//500 + 1) d = coindiff(N,n1,n2,n3,n4) if d > maxdiff: maxdiff = d ans = {10:n1,50:n2,100:n3,500:n4} for k,v in sorted(ans.items()): if v == 0: continue print('{0} {1}'.format(k, v))
s487168212
p01132
u136916346
1530362770
Python
Python3
py
Runtime Error
0
0
317
while 1: n=int(input()) if not n:break a,b,c,d=map(int,input().split()) y=(10,50,100,500) l=[[i,j,k,l] for i in range(a+1) for j in range(b+1) for k in range(c+1) for l in range(d+1) if i*10+j*50+k*100+l*500==n] t=sorted(l,key=lambda x:sum(x))[-1] [print(i,j) for (i,j) in zip(y,t) if j]
s200474170
p01132
u136916346
1530362910
Python
Python3
py
Runtime Error
0
0
329
while 1: n=int(input()) if not n:break a,b,c,d=map(int,input().split()) y=(10,50,100,500) l=[[i,j,k,l] for i in range(a+1) for j in range(b+1) for k in range(c+1) for l in range(d+1) if i*10+j*50+k*100+l*500==n] t=sorted(l,key=lambda x:sum(x))[-1] [print(i,j) for (i,j) in zip(y,t) if j] print()
s268826257
p01132
u136916346
1530367902
Python
Python3
py
Runtime Error
0
0
342
while 1: n=int(input()) if not n:break a,b,c,d=map(int,input().split()) y=(10,50,100,500) l=[[i,j,k,l] for i in range(a+1) for j in range(b+1) for k in range(c+1) for l in range(d+1) if i*10+j*50+k*100+l*500==n] t=sorted(l,key=lambda x:sum(x))[-1] es=[a-t[0],b-t[1],c-t[2],d-t[3]] print(es) print(es)
s357435958
p01132
u136916346
1530368606
Python
Python3
py
Runtime Error
0
0
385
while 1: n=int(input()) if not n:break a,b,c,d=map(int,input().split()) y=(10,50,100,500) l=[[i,j,k,l] for i in range(a+1) for j in range(b+1) for k in range(c+1) for l in range(d+1) if i*10+j*50+k*100+l*500==n] t=sorted(l,key=lambda x:sum(x))[-1] es=[((a-t[0])//5)*5,((b-t[1])//2)*2,((c-t[2])//5)*5,0] [print(i,j+k) for (i,j,k) in zip(y,t,es) if j+k]
s513422661
p01132
u136916346
1530368622
Python
Python3
py
Runtime Error
0
0
396
while 1: n=int(input()) if not n:break a,b,c,d=map(int,input().split()) y=(10,50,100,500) l=[[i,j,k,l] for i in range(a+1) for j in range(b+1) for k in range(c+1) for l in range(d+1) if i*10+j*50+k*100+l*500==n] t=sorted(l,key=lambda x:sum(x))[-1] es=[((a-t[0])//5)*5,((b-t[1])//2)*2,((c-t[2])//5)*5,0] [print(i,j+k) for (i,j,k) in zip(y,t,es) if j+k] print()
s224672086
p01132
u779627195
1352822802
Python
Python
py
Runtime Error
19930
5596
980
while 1: m = int(raw_input()) if m == 0: break cm = [10, 50, 100, 500] c = map(int, raw_input().split()) mintn = 81 fc = [0 for i in xrange(4)] for i in xrange(c[0]+1): for j in xrange(c[1]+1): for k in xrange(c[2]+1): for l in xrange(c[3]+1): t = i*cm[0] + j*cm[1] + k*cm[2] + l*cm[3] if t >= m: mc = [0 for n in xrange(4)] mc = [c[0]-i,c[1]-j,c[2]-k,c[3]-l] ch = t-m for n in xrange(3,-1,-1): while(ch >= cm[n]): ch -= cm[n] mc[n] += 1 tn = sum(mc) if (tn < mintn): mintn = tn fc = [i,j,k,l] for i in xrange(4): if fc[i] != 0: print "%d %d" % (cm[i], fc[i]) print ''
s625964490
p01132
u109084363
1360310226
Python
Python
py
Runtime Error
19920
4272
843
def coin(n): return n / 500 + (n % 500) / 100 + (n % 100) / 50 + (n % 50) / 10 while True: n = int(raw_input()) if n == 0: break c10, c50, c100, c500 = map(int, raw_input().split()) m = 20000 result = [] for i in xrange(c10 + 1): for j in xrange(c50 + 1): for k in xrange(c100 + 1): for l in xrange(c500 + 1): money = 500 * l + 100 * k + 50 * j + 10 * i if money >= n: if coin(money - n) < m: m = coin(money - n) result = [i, j, k, l] if result[0] != 0: print 10, result[0] if result[1] != 0: print 50, result[1] if result[2] != 0: print 100, result[2] if result[3] != 0: print 500, result[3] print
s495224459
p01132
u109084363
1360341105
Python
Python
py
Runtime Error
19930
4316
995
def coin(n): return n / 500 + (n % 500) / 100 + (n % 100) / 50 + (n % 50) / 10 ret = '' while True: n = int(raw_input()) if n == 0: break c10, c50, c100, c500 = map(int, raw_input().split()) m = 20000 result = [] for i in xrange(c10 + 1): for j in xrange(c50 + 1): for k in xrange(c100 + 1): for l in xrange(c500 + 1): money = 500 * l + 100 * k + 50 * j + 10 * i if money >= n: if coin(money - n) < m: m = coin(money - n) result = [i, j, k, l] if result[0] != 0: ret += '10 ' + str(result[0]) ret += '\n' if result[1] != 0: ret += '50 ' + str(result[1]) ret += '\n' if result[2] != 0: ret += '100 ' + str(result[2]) ret += '\n' if result[3] != 0: ret += '500 ' + str(result[3]) ret += '\n' ret += '\n' print ret[:-1]
s284996893
p01132
u109084363
1360387774
Python
Python
py
Runtime Error
19930
4316
995
def coin(n): return n / 500 + (n % 500) / 100 + (n % 100) / 50 + (n % 50) / 10 ret = '' while True: n = int(raw_input()) if n == 0: break c10, c50, c100, c500 = map(int, raw_input().split()) m = 20000 result = [] for i in xrange(c10 + 1): for j in xrange(c50 + 1): for k in xrange(c100 + 1): for l in xrange(c500 + 1): money = 500 * l + 100 * k + 50 * j + 10 * i if money >= n: if coin(money - n) < m: m = coin(money - n) result = [i, j, k, l] if result[0] != 0: ret += '10 ' + str(result[0]) ret += '\n' if result[1] != 0: ret += '50 ' + str(result[1]) ret += '\n' if result[2] != 0: ret += '100 ' + str(result[2]) ret += '\n' if result[3] != 0: ret += '500 ' + str(result[3]) ret += '\n' ret += '\n' print ret[:-1]
s300329862
p01132
u109084363
1360389072
Python
Python
py
Runtime Error
19930
4236
637
def coin(n): return n / 500 + (n % 500) / 100 + (n % 100) / 50 + (n % 50) / 10 ret = '' while True: n = int(raw_input()) if n == 0: break c10, c50, c100, c500 = map(int, raw_input().split()) m = 20000 result = [] for i in xrange(c10 + 1): for j in xrange(c50 + 1): for k in xrange(c100 + 1): for l in xrange(c500 + 1): money = 500 * l + 100 * k + 50 * j + 10 * i if money >= n: if coin(money - n) < m: m = coin(money - n) result = [i, j, k, l]
s816950728
p01132
u109084363
1360389281
Python
Python
py
Runtime Error
0
0
732
def coin(n): return [(n % 500) / 100, (n % 100) / 50, (n % 50) / 10, n / 500] ret = '' while True: n = int(raw_input()) if n == 0: break c10, c50, c100, c500 = map(int, raw_input().split()) m = 20000 result = [] money = 500 * l + 100 * k + 50 * j + 10 * i result = coin(money - n) if result[0] - c10 != 0: ret += '10 ' + str(result[0] - c10) ret += '\n' if result[1] - c50 != 0: ret += '50 ' + str(result[1] - c50) ret += '\n' if result[2] - c100 != 0: ret += '100 ' + str(result[2] - c100) ret += '\n' if result[3] - c500 != 0: ret += '500 ' + str(result[3] - c500) ret += '\n' ret += '\n' print ret[:-1]
s349301078
p01132
u109084363
1360389353
Python
Python
py
Runtime Error
0
0
293
def coin(n): return [(n % 500) / 100, (n % 100) / 50, (n % 50) / 10, n / 500] ret = '' while True: n = int(raw_input()) if n == 0: break c10, c50, c100, c500 = map(int, raw_input().split()) m = 20000 result = [] money = 500 * l + 100 * k + 50 * j + 10 * i
s591627092
p01132
u647766105
1392280403
Python
Python
py
Runtime Error
39860
4416
1016
from itertools import product L = [10, 50, 100, 500] def solve(): #print N ans = [[20] * 4, [20] * 4] for c in product(*[range(N[i] + 1) for i in xrange(4)]): #print "out", c r = calc(c) #print "in", r if check(c, r): ans = min([r, c], ans, key = lambda x: sum(x[0])) #print "check", ans #print return ans[1] def calc(N): r = sum(L[i] * N[i] for i in xrange(4)) - M #print r if r < 0: return [-1] * 4 ret = [0] * 4 for i in xrange(3, -1, -1): ret[i] += r / L[i] r -= ret[i] * L[i] return ret def check(N1, N2): if N2[0] == -1: return False for c1, c2 in zip(N1, N2): if c1 > 0 and c2 > 0: return False return True M = int(raw_input()) while True: N = map(int, raw_input().split()) for i, n in zip(L, solve()): if n == 0: continue print i, n M = int(raw_input()) if M == 0: break print
s826469607
p01133
u797673668
1461568483
Python
Python3
py
Runtime Error
40000
7876
862
from math import sqrt def dfs(remains, elapsed, hx, hy): global crystals if not remains: return True remains_c = set() for i in remains: cx, cy, dfd = crystals[i] dfh = sqrt((cx - hx) ** 2 + (cy - hy) ** 2) new_elapsed = elapsed + dfh if dfd <= new_elapsed: return False remains_c.add((i, cx, cy, new_elapsed)) for i, cx, cy, new_elapsed in remains_c: remains.discard(i) if dfs(remains, new_elapsed, cx, cy): return True remains.add(i) return False while True: n, hx, hy, dx, dy = map(int, input().split()) if n == 0: break crystals = [(cx, cy, sqrt((cx - dx) ** 2 + (cy - dy) ** 2)) for cx, cy in (map(int, input().split()) for _ in range(n))] print('YES' if dfs(set(range(n)), 0, hx, hy) else 'NO')
s231014519
p01133
u797673668
1461569210
Python
Python3
py
Runtime Error
40000
7796
843
from math import sqrt def dfs(remains, elapsed, hx, hy): global crystals if not remains: return True remains_c = set() for i in remains: cx, cy, dfd = crystals[i] new_elapsed = elapsed + sqrt((cx - hx) ** 2 + (cy - hy) ** 2) if dfd <= new_elapsed: return False remains_c.add((i, cx, cy, new_elapsed)) for i, cx, cy, new_elapsed in remains_c: remains.remove(i) if dfs(remains, new_elapsed, cx, cy): return True remains.add(i) return False while True: n, hx, hy, dx, dy = map(int, input().split()) if n == 0: break crystals = [(cx, cy, sqrt((cx - dx) ** 2 + (cy - dy) ** 2)) for cx, cy in (map(int, input().split()) for _ in range(n))] print('YES' if dfs(set(range(n)), 0, hx, hy) else 'NO')
s289002245
p01133
u779627195
1353511536
Python
Python
py
Runtime Error
19930
35000
982
import sys import math EPS = 10**(-10) def solve(t,x,y): global ans global done if ans: return cnt = 0 for i in xrange(len(c)): if done[i]: cnt += 1 if cnt is n: ans = True return for i in xrange(len(c)): if done[i]: continue nt = t + math.hypot(c[i][0]-x, c[i][1]-y) if math.hypot(dx-c[i][0], dy-c[i][1]) < nt + EPS: return for i in xrange(len(c)-1, -1, -1): if done[i]: continue #print sys.stderr, i,c[i],len(c) done[i] = True nt = t + math.hypot(c[i][0]-x, c[i][1]-y) solve(nt,c[i][0],c[i][1]) done[i] = False while 1: n,hx,hy,dx,dy = map(int, raw_input().split()) if not(n or hx or hy or dx or dy): break c = [] ans = False for i in xrange(n): x,y = map(int, raw_input().split()) c.append((x,y)) done = [False for i in xrange(len(c))] solve(0.0,hx,hy) if ans: print 'YES' else: print 'NO'
s559163443
p01134
u536089081
1555920398
Python
Python3
py
Runtime Error
0
0
1094
from itertools import combinations from decimal import Decimal def get_point(line1, line2): m1, k1 = line1 m2, k2 = line2 if m1 == m2: return None elif m1 is None and m2 is None: return None elif m1 is None: x = k1 y = m2 * x + k2 elif m2 is None: x = k2 y = m1 * x + k1 else: x = (k2-k1)/(m2-m1) y = m1*x+k return (x, y) while True: N = int(input()) if not N: break lines = [] for i in range(N): x1, y1, x2, y2 = [Decimal(int(i)) for i in input().split()] if x1 == x2: lines.append(None, x1) else: m = (y2-y1) / (x2-x1) k = y1 - m * x1 lines.append((m, k)) iterated_lines = [] ans = 1 for line1 in lines: pt_set = set() for line2 in iterated_lines: pt = get_point(line1, line2) # print(pt) if pt: pt_set.add(pt) ans += len(pt_set) + 1 iterated_lines.append(line1) print(ans)
s313263491
p01134
u536089081
1555920815
Python
Python3
py
Runtime Error
0
0
1155
from itertools import combinations from decimal import Decimal def get_point(line1, line2): m1, k1 = line1 m2, k2 = line2 if m1 == m2: return None elif m1 is None and m2 is None: return None elif m1 is None: x = k1 y = m2 * x + k2 elif m2 is None: x = k2 y = m1 * x + k1 else: x = (k2-k1)/(m2-m1) y = m1*x+k if -100 < x < 100 and -100 < y < 100: return (x, y) else: return None while True: N = int(input()) if not N: break lines = [] for i in range(N): x1, y1, x2, y2 = [Decimal(int(i)) for i in input().split()] if x1 == x2: lines.append(None, x1) else: m = (y2-y1) / (x2-x1) k = y1 - m * x1 lines.append((m, k)) iterated_lines = [] ans = 1 for line1 in lines: pt_set = set() for line2 in iterated_lines: pt = get_point(line1, line2) # print(pt) if pt: pt_set.add(pt) ans += len(pt_set) + 1 iterated_lines.append(line1) print(ans)
s369156375
p01134
u536089081
1555920844
Python
Python3
py
Runtime Error
0
0
1155
from itertools import combinations from decimal import Decimal def get_point(line1, line2): m1, k1 = line1 m2, k2 = line2 if m1 == m2: return None elif m1 is None and m2 is None: return None elif m1 is None: x = k1 y = m2 * x + k2 elif m2 is None: x = k2 y = m1 * x + k1 else: x = (k2-k1)/(m2-m1) y = m1*x+k if -100 < x < 100 and -100 < y < 100: return (x, y) else: return None while True: N = int(input()) if not N: break lines = [] for i in range(N): x1, y1, x2, y2 = [Decimal(int(i)) for i in input().split()] if x1 == x2: lines.append(None, x1) else: m = (y2-y1) / (x2-x1) k = y1 - m * x1 lines.append((m, k)) iterated_lines = [] ans = 1 for line1 in lines: pt_set = set() for line2 in iterated_lines: pt = get_point(line1, line2) # print(pt) if pt: pt_set.add(pt) ans += len(pt_set) + 1 iterated_lines.append(line1) print(ans)
s307913885
p01134
u467175809
1530296422
Python
Python
py
Runtime Error
0
0
1598
#!/usr/bin/env python from collections import deque import itertools as it import sys import math sys.setrecursionlimit(1000000) def gcd(a, b): if b == 0: return a a1 = b b1 = a % b return gcd(a1, b1) while True: n = int(input()) if n == 0: break line = [] for loop in range(n): x1, y1, x2, y2 = list(map(int, input().split())) # ax + by + c = 0 a = y1 - y2 b = x2 - x1 c = -x1 * a - y1 * b line.append((a, b, c)) ans = n + 1 m = {} for i in range(n): for j in range(i + 1, n): l1 = line[i] l2 = line[j] det = l1[0] * l2[1] - l1[1] * l2[0] deta = int(abs(det)) if det == 0: continue x = l2[1] * l1[2] - l1[1] * l2[2] y = -l2[0] * l1[2] + l1[0] * l2[2] if x > -100 * deta and x < 100 * deta and y > -100 * deta and y < 100 * deta: ans += 1 G = gcd(gcd(int(abs(x)), int(abs(y))), int(abs(det))) x //= G y //= G det //= G if det < 0: x *= -1 y *= -1 det *= -1 if (x, y, det) in m: m[(x, y, det)] += 1 else: m[(x, y, det)] = 1 for p in m: S = 0 cnt = 0 while True: S += cnt if m[p] == S: ans -= cnt * (cnt - 1) // 2 break cnt += 1 print(ans)
s791759622
p01134
u467175809
1530296606
Python
Python3
py
Runtime Error
0
0
1290
#!/usr/bin/env python from collections import deque import itertools as it import sys import math sys.setrecursionlimit(1000000) def gcd(a, b): if b == 0: return a a1 = b b1 = a % b return gcd(a1, b1) while True: n = int(input()) if n == 0: break line = [] for loop in range(n): x1, y1, x2, y2 = list(map(int, input().split())) # ax + by + c = 0 a = y1 - y2 b = x2 - x1 c = -x1 * a - y1 * b line.append((a, b, c)) m = {} for i in range(n): for j in range(i + 1, n): l1 = line[i] l2 = line[j] det = l1[0] * l2[1] - l1[1] * l2[0] deta = int(abs(det)) if det == 0: continue x = l2[1] * l1[2] - l1[1] * l2[2] y = -l2[0] * l1[2] + l1[0] * l2[2] if x > -100 * deta and x < 100 * deta and y > -100 * deta and y < 100 * deta: ans += 1 G = gcd(gcd(int(abs(x)), int(abs(y))), int(abs(det))) x //= G y //= G det //= G if det < 0: x *= -1 y *= -1 det *= -1 m[(x, y, det)] = 1 print(1 + n + len(m))
s503989763
p01136
u536089081
1555920803
Python
Python3
py
Runtime Error
0
0
1155
from itertools import combinations from decimal import Decimal def get_point(line1, line2): m1, k1 = line1 m2, k2 = line2 if m1 == m2: return None elif m1 is None and m2 is None: return None elif m1 is None: x = k1 y = m2 * x + k2 elif m2 is None: x = k2 y = m1 * x + k1 else: x = (k2-k1)/(m2-m1) y = m1*x+k if -100 < x < 100 and -100 < y < 100: return (x, y) else: return None while True: N = int(input()) if not N: break lines = [] for i in range(N): x1, y1, x2, y2 = [Decimal(int(i)) for i in input().split()] if x1 == x2: lines.append(None, x1) else: m = (y2-y1) / (x2-x1) k = y1 - m * x1 lines.append((m, k)) iterated_lines = [] ans = 1 for line1 in lines: pt_set = set() for line2 in iterated_lines: pt = get_point(line1, line2) # print(pt) if pt: pt_set.add(pt) ans += len(pt_set) + 1 iterated_lines.append(line1) print(ans)
s360328453
p01136
u041086527
1416330941
Python
Python
py
Runtime Error
0
0
457
while True: n = input() if (n == 0): break d = [] for i in range(n): a = map(int, raw_input().split()) d.append(a[1:]) for i in range(31): ok = True for j in d: t = min(j) if (i < t): ok = False break if (ok): print i break if (ok): continue else: print -1
s559186931
p01136
u041086527
1416334476
Python
Python
py
Runtime Error
19930
4388
849
while True: n = input() if (n == 0): break d = [] digit = set() for i in range(n): a = map(int, raw_input().split()) for j in a[1:]: digit.add(j) d.append(a[1:]) paper = [set() for i in range(n)] ans = 31 for i in range(n): paper[i].add(i) for i in digit: for j in range(len(d)): if i in d[j]: for k in range(j, len(d)): if i in d[k]: for l in paper[k]: paper[j].add(l) for l in paper[j]: paper[k].add(l) for j in range(len(d)): if (len(paper[j]) == n): ans = min(ans, i) if (ans != 31): print ans else: print -1
s924975665
p01136
u041086527
1416335095
Python
Python
py
Runtime Error
19930
4384
847
while True: n = input() if (n == 0): break d = [] digit = set() for i in range(n): a = map(int, raw_input().split()) for j in a[1:]: digit.add(j) d.append(a[1:]) paper = [set() for i in range(n)] ans = 31 for i in range(n): paper[i].add(i) for i in digit: for j in range(len(d)): if i in d[j]: for k in range(j, len(d)): if i in d[k]: for l in paper[k]: paper[j].add(l) for l in paper[j]: paper[k].add(l) for j in range(len(d)): if (len(paper[j]) == n): ans = min(ans, i) if (ans != 31): print ans else: print -1
s920521021
p01136
u011621222
1527763247
Python
Python3
py
Runtime Error
0
0
885
while(True): n = int(input()) if n == 0: exit() d = [] for i in range(n): ll = input().split() l = [int(_) for _ in ll] f = l[0] tmp = [] for j in range(1, f+1): tmp.append(l[j]) d += [tmp] mp = [[0 for i in range(30)] for j in range(n)] for member in range(n): for day in d[member]: mp[member][day] = 1 clr = [0 for i in range(n)] ans = [1 for i in range(n)] flg = 0 for day in range(30): tmp = [] s = 0 for member in range(n): s += mp[member][day] if mp[member][day] == 1: tmp.append(member) if s > 1: for member in tmp: clr[member] = 1 if clr == ans and flg == 0: print(day) flg = 1 if flg == 0: print(-1)
s730120877
p01136
u011621222
1527763287
Python
Python3
py
Runtime Error
0
0
884
while(True): n = int(input()) if n == 0: break d = [] for i in range(n): ll = input().split() l = [int(_) for _ in ll] f = l[0] tmp = [] for j in range(1, f+1): tmp.append(l[j]) d += [tmp] mp = [[0 for i in range(30)] for j in range(n)] for member in range(n): for day in d[member]: mp[member][day] = 1 clr = [0 for i in range(n)] ans = [1 for i in range(n)] flg = 0 for day in range(30): tmp = [] s = 0 for member in range(n): s += mp[member][day] if mp[member][day] == 1: tmp.append(member) if s > 1: for member in tmp: clr[member] = 1 if clr == ans and flg == 0: print(day) flg = 1 if flg == 0: print(-1)
s892598770
p01136
u352394527
1530537301
Python
Python3
py
Runtime Error
0
0
646
while True: n = int(input()) if n == 0: break days = [[] for _ in range(30)] for i in range(n): hima = list(map(int, input().split())) for d in hima[1:]: days[d].append(i) par_lst = [i for i in range(n)] def get_par(x): if x == par_lst[x]: return x ret = get_par(par_lst[x]) par_lst[x] = ret return ret for i, lst in enumerate(days, start=1): par = get_par(0) for i in range(n): if get_par(i) != par: break else: print(i) break if lst: par = get_par(lst[0]) for num in lst: par_lst[get_par(num)] = par else: print(-1)
s686361586
p01137
u741801763
1530979103
Python
Python3
py
Runtime Error
0
0
233
while 1: e = int(input().strip()) if e ==0:break m=e for z in range(e): for y in range(e): x = e - y**2 - z**3 if x < 0:break if m > x+y+z: m = x+y+z print(m)
s802868857
p01137
u741801763
1530979435
Python
Python3
py
Runtime Error
0
0
252
import math while 1: e = int(input().strip()) if e ==0:break m=e for z in range(e): for y in range(int(math.sqrt(e))): x = e - y**2 - z**3 if x < 0:break if m > x+y+z: m = x+y+z print(m)
s811183537
p01137
u741801763
1530980358
Python
Python3
py
Runtime Error
0
0
267
import math while 1: e = int(input().strip()) if e ==0:break m=e for z in range(int(math.sqrt(e))): for y in range(int(math.sqrt(e))): x = e - y*y- z*z*z if x < 0:break if m > x+y+z: m = x+y+z print(m)
s457295303
p01137
u741801763
1530981189
Python
Python3
py
Runtime Error
0
0
287
while 1: e = int(input().strip()) if e ==0:break m=e z =0 while z**3 <= e: y =0 while y**2 <= e - z**3: x = e - y**2- z**3 if x < 0:break if m > x+y+z: m = x+y+z y+=1 z+=1 print(m)
s059838418
p01137
u741801763
1531128369
Python
Python3
py
Runtime Error
0
0
253
while 1: e = int(input().strip()) if e ==0:break m=e z =0 while z**3 <= e: y=0 while y **2 <= e - z**3: x = e - y**2 - z**3 if m > x+y+z: m = x+y+z y+=1 z+=1 print(m)
s918641480
p01137
u741801763
1531128894
Python
Python3
py
Runtime Error
0
0
289
import time while 1: e = int(input().strip()) if e ==0:break m=e z =0 time.sleep(20) while z**3 <= e: y=0 while y **2 <= e - z**3: x = e - y**2 - z**3 if m > x+y+z: m = x+y+z y+=1 z+=1 print(m)
s138617677
p01137
u617183767
1420627927
Python
Python
py
Runtime Error
19930
4696
683
#! /usr/bin/env python # -*- coding: utf-8 -*- import os import sys import itertools import math from collections import Counter, defaultdict class Main(object): def __init__(self): pass def solve(self): ''' insert your code ''' while True: e = input() if e == 0: break m = float('inf') for z in range(101): for y in range(1001): x = e - z ** 3 - y ** 2 if x >= 0: m = min(m, x + y + z) print m return None if __name__ == '__main__': m = Main() m.solve()
s622113524
p01137
u617183767
1420628269
Python
Python
py
Runtime Error
19930
4700
683
#! /usr/bin/env python # -*- coding: utf-8 -*- import os import sys import itertools import math from collections import Counter, defaultdict class Main(object): def __init__(self): pass def solve(self): ''' insert your code ''' while True: e = input() if e == 0: break m = float('inf') for z in range(101): for y in range(1001): x = e - z ** 3 - y ** 2 if x >= 0: m = min(m, x + y + z) print m return None if __name__ == '__main__': m = Main() m.solve()
s576180343
p01137
u617183767
1420628687
Python
Python
py
Runtime Error
19930
4700
829
#! /usr/bin/env python # -*- coding: utf-8 -*- import os import sys import itertools import math from collections import Counter, defaultdict class Main(object): def __init__(self): pass def solve(self): ''' insert your code ''' while True: e = input() if e == 0: break m = float('inf') for z in range(101): tmp = e - z ** 3 if tmp < 0: continue for y in range(1001): x = e - z ** 3 - y ** 2 if x >= 0: m = min(m, x + y + z) else: break print m return None if __name__ == '__main__': m = Main() m.solve()
s713633933
p01137
u316268279
1421853290
Python
Python3
py
Runtime Error
0
0
312
#!/usr/bin/env python # -*- coding: utf-8 -*- from math import sqrt while True: e = int(input()) if e == 0: break ans = 10**9 for z in range(e): if z > e: break y = int(sqrt(e-z**3)) x = e - y ** 2 - z ** 3 ans = min(ans,x+y+i) print(ans)
s744827630
p01137
u731235119
1421952298
Python
Python
py
Runtime Error
19930
4404
231
import math while 1 : e = int(raw_input()) if e == 0: break z = 0 m = e while math.pow(z,3) <= e: y = 0 while y ** 2 <= e - math.pow(z,3): m = min(e + y + z - y**2 - math.pow(z,3), m) y += 1 z += 1 print int(m)
s516460520
p01137
u731235119
1421956008
Python
Python
py
Runtime Error
19930
4408
250
import math while 1 : e = int(raw_input()) if e == 0: break z = 0 m = e while math.pow(z,3) <= e: y = 0 while y ** 2 <= e - math.pow(z,3): m = min(e + y + z - y**2 - math.pow(z,3), m) y += 1 z += 1 print y, z print int(m) quit()