buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
def g gets.to_i end g.times{puts (a=g+g)>10**80?:overflow:a}
def g gets.to_i end g.times{puts (a=g+g)>=10**80?:overflow:a}
[["-", 0, 652, 3, 4, 0, 754, 15, 738, 17, 47], ["+", 0, 652, 3, 4, 0, 754, 15, 738, 17, 20]]
4
27
2
#!/usr/bin/ruby n = STDIN.gets.to_i n.times do |i| sum = STDIN.gets.to_i + STDIN.gets.to_i puts sum > 10**79 ? "overflow" : sum end
#!/usr/bin/ruby n = STDIN.gets.to_i n.times do |i| sum = STDIN.gets.to_i + STDIN.gets.to_i puts sum >= 10**80 ? "overflow" : sum end
[["-", 0, 652, 3, 4, 0, 754, 15, 738, 17, 47], ["+", 0, 652, 3, 4, 0, 754, 15, 738, 17, 20], ["-", 3, 4, 0, 754, 15, 738, 12, 738, 12, 612], ["+", 3, 4, 0, 754, 15, 738, 12, 738, 12, 612]]
4
41
4
def writeSum number1 = gets.to_i number2 = gets.to_i sum = number1 + number2 if sum >= 10 ** 81 puts "overflow" else puts sum end end dataSet = gets.to_i 1.upto(dataSet) do |i| writeSum() end
def writeSum number1 = gets.to_i number2 = gets.to_i sum = number1 + number2 if sum >= 10 ** 80 puts "overflow" else puts sum end end dataSet = gets.to_i 1.upto(dataSet) do |i| writeSum() end
[["-", 8, 736, 0, 121, 15, 738, 12, 738, 12, 612], ["+", 8, 736, 0, 121, 15, 738, 12, 738, 12, 612]]
4
51
2
i=gets.to_i i.times do a=gets.to_i b=gets.to_i add=a+b add=add.to_s.length if add<80 print a+b,"\n" else print "overflow\n" end end
i=gets.to_i i.times do a=gets.to_i b=gets.to_i add=a+b add=add.to_s.length if add<=80 print a+b,"\n" else print "overflow\n" end end
[["-", 196, 737, 8, 736, 0, 121, 15, 738, 17, 18], ["+", 196, 737, 8, 736, 0, 121, 15, 738, 17, 19]]
4
51
2
gets.chomp.to_i.times do a = gets.to_i b = gets.to_i if (sum = a + b) > 10**80 puts 'overflow' else puts sum end end
gets.chomp.to_i.times do a = gets.to_i b = gets.to_i if (sum = a + b) >= 10**80 puts 'overflow' else puts sum end end
[["-", 196, 737, 8, 736, 0, 121, 15, 738, 17, 47], ["+", 196, 737, 8, 736, 0, 121, 15, 738, 17, 20]]
4
39
2
a = gets.chomp!.to_i a.times do b = gets c = gets if (b.to_i + c.to_i).to_s.length >= 80 puts 'overflow' else puts b.to_i + c.to_i end end
a = gets.chomp!.to_i a.times do b = gets c = gets if (b.to_i + c.to_i).to_s.length > 80 puts 'overflow' else puts b.to_i + c.to_i end end
[["-", 196, 737, 8, 736, 0, 121, 15, 738, 17, 20], ["+", 196, 737, 8, 736, 0, 121, 15, 738, 17, 47]]
4
48
2
(n=gets.to_i).times{puts((a=gets.to_i+gets.to_i)>=10**80?"overfllow":a)}
(n=gets.to_i).times{puts((a=gets.to_i+gets.to_i)>=10**80?"overflow":a)}
[["-", 0, 652, 3, 4, 0, 754, 64, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 754, 64, 557, 0, 6]]
4
35
2
n = gets.to_i n.times do sum = gets.to_i + gets.to_i puts sum.size >= 80 ? 'overflow' : sum end
n = gets.to_i n.times do sum = gets.to_i + gets.to_i puts sum.to_s.length >= 81 ? 'overflow' : sum end
[["-", 3, 4, 0, 754, 15, 738, 31, 652, 735, 22], ["+", 0, 754, 15, 738, 31, 652, 486, 652, 735, 22], ["+", 3, 4, 0, 754, 15, 738, 31, 652, 17, 131], ["+", 3, 4, 0, 754, 15, 738, 31, 652, 735, 22], ["-", 0, 652, 3, 4, 0, 754, 15, 738, 12, 612], ["+", 0, 652, 3, 4, 0, 754, 15, 738, 12, 612]]
4
31
6
n = gets.to_i 1.upto(n) do |i| sum = gets.to_i + gets.to_i puts sum.size > 80 ? 'overflow' : sum end # ruby <3
n = gets.to_i 1.upto(n) do |_i| sum = gets.to_i + gets.to_i puts sum.to_s.size > 80 ? 'overflow' : sum end # ruby <3
[["-", 0, 493, 0, 652, 196, 737, 54, 758, 0, 22], ["+", 0, 493, 0, 652, 196, 737, 54, 758, 0, 22], ["+", 0, 754, 15, 738, 31, 652, 486, 652, 17, 131], ["+", 0, 754, 15, 738, 31, 652, 486, 652, 735, 22]]
4
38
4
num = gets.to_i while num > 0 num1 = gets.to_i num2 = gets.to_i ans = num2+num1 if ans >= 10e80 then puts "overflow" else puts ans end num = num - 1 end
num = gets.to_i while num > 0 num1 = gets.to_i num2 = gets.to_i ans = num2+num1 if ans >= 100000000000000000000000000000000000000000000000000000000000000000000000000000000 then puts "overflow" else puts ans end num = num - 1 end
[["-", 0, 89, 8, 170, 0, 121, 15, 738, 12, 531], ["+", 0, 89, 8, 170, 0, 121, 15, 738, 12, 612]]
4
43
4
num = gets.to_i while num > 0 num1 = gets.to_i num2 = gets.to_i ans = num2+num1 if ans >= 10e80 then puts "overflow" else puts ans end num = num - 1 end
num = gets.to_i while num > 0 num1 = gets.to_i num2 = gets.to_i ans = num2+num1 if ans >= 10**80 then puts "overflow" else puts ans end num = num - 1 end
[["-", 0, 89, 8, 170, 0, 121, 15, 738, 12, 531], ["+", 8, 170, 0, 121, 15, 738, 12, 738, 31, 612], ["+", 8, 170, 0, 121, 15, 738, 12, 738, 17, 578], ["+", 8, 170, 0, 121, 15, 738, 12, 738, 12, 612]]
4
43
4
gets.to_i.times do sum = gets.to_i + gets.to_i puts 10**80 < sum ? 'overflow' : sum end
gets.to_i.times do sum = gets.to_i + gets.to_i puts 10**80 <= sum ? 'overflow' : sum end
[["-", 0, 652, 3, 4, 0, 754, 15, 738, 17, 18], ["+", 0, 652, 3, 4, 0, 754, 15, 738, 17, 19]]
4
28
2
n=int(input()) for i in range(n): a=int(input()) b=int(input()) if a+b>=10**79:print("overflow") else:print(a+b)
n=int(input()) for i in range(n): a=int(input()) b=int(input()) if a+b>=10**80:print("overflow") else:print(a+b)
[["-", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612]]
5
55
2
# python template for atcoder1 import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline n = int(input()) ans = [] for _ in range(n): a = int(input()) b = int(input()) s = a+b if s >= 10**79: ans.append("overflow") else: ans.append(str(s)) print("\n".join(ans))
# python template for atcoder1 import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline n = int(input()) ans = [] for _ in range(n): a = int(input()) b = int(input()) s = a+b if s > 10**80-1: ans.append("overflow") else: ans.append(str(s)) print("\n".join(ans))
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["-", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612], ["+", 0, 57, 15, 666, 0, 657, 31, 657, 12, 612], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 33], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612]]
5
96
6
while(True): try: n = eval(input()) for i in range(n): a = eval(input()) b = eval(input()) c = str(a + b) if(len(c) >= 80): print("overflow") else: print(c) except Exception: break
while(True): try: n = eval(input()) for i in range(n): a = eval(input()) b = eval(input()) c = str(a + b) if(len(c) > 80): print("overflow") else: print(c) except Exception: break
[["-", 8, 196, 0, 57, 15, 23, 0, 666, 667, 20], ["+", 8, 196, 0, 57, 15, 23, 0, 666, 667, 47]]
5
73
2
n = int(input()) for _ in range(n): a = sum([int(input()) for _ in range(n)]) print(a if a < 10**80 else 'overflow')
n = int(input()) for _ in range(n): a = sum([int(input()) for _ in range(2)]) print(a if a < 10**80 else 'overflow')
[["-", 0, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 0, 658, 0, 659, 12, 652, 3, 4, 0, 612]]
5
50
2
m=10**79 n=eval(input()) for i in range(n): s="overflow" a=eval(input()) b=eval(input()) if a<m and b<m: tmp=a+b if tmp<m: s=tmp print(s)
m=10**80 n=eval(input()) for i in range(n): s="overflow" a=eval(input()) b=eval(input()) if a<m and b<m: tmp=a+b if tmp<m: s=tmp print(s)
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612]]
5
68
2
import sys f = sys.stdin n = int(f.readline()) for _ in range(n): a = f.readline().strip() b = f.readline().strip() c = int(a) + int(b) c = '{}'.format(c) print(c if len(c) else 'overflow')
import sys f = sys.stdin n = int(f.readline()) for _ in range(n): a = f.readline().strip() b = f.readline().strip() c = int(a) + int(b) c = '{}'.format(c) print(c if len(c) <= 80 else 'overflow')
[["+", 0, 652, 3, 4, 0, 41, 0, 666, 667, 19], ["+", 0, 652, 3, 4, 0, 41, 0, 666, 0, 612]]
5
81
2
a=eval(input()) for i in range(2): x=eval(input()) y=eval(input()) if len(x+y)>80: print("overflow") else: print(x+y)
a=eval(input()) for i in range(a): x=eval(input()) y=eval(input()) if len(str(x+y))>80: print("overflow") else: print(x+y)
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 15, 666, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
56
5
#!/usr/bin/env python # -*- coding: utf-8 -*- import math n = int(input()); over = 10 ** 80; for i in range(0, n): a = int(input()); b = int(input()); if a + b > over: print("overflow") else: print(a + b);
#!/usr/bin/env python # -*- coding: utf-8 -*- import math n = int(input()); over = 10 ** 80; for i in range(0, n): a = int(input()); b = int(input()); if a + b >= over: print("overflow") else: print(a + b);
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20]]
5
69
2
# -*- coding:utf-8 -*- def main(): for i in range(int(input())): a=int(input())+int(input()) if a>=10**80: print("overflow") print(a) if __name__ == '__main__': main()
# -*- coding:utf-8 -*- def main(): for i in range(int(input())): a=int(input())+int(input()) if a>=10**80: print("overflow") else: print(a) if __name__ == '__main__': main()
[["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 102]]
5
61
2
import math N = int(input()) for i in range(N): a = int(input()) b = int(input()) if a >= 10**79 or b >= 10 ** 79 or a + b >= 10 ** 79: print("overflow") else: print(a + b)
import math N = int(input()) for i in range(N): a = int(input()) b = int(input()) if a >= 10 ** 80 or b >= 10 ** 80 or a + b >= 10 ** 80: print("overflow") else: print(a + b)
[["-", 15, 679, 31, 679, 31, 666, 0, 657, 12, 612], ["+", 15, 679, 31, 679, 31, 666, 0, 657, 12, 612], ["-", 15, 679, 31, 679, 12, 666, 0, 657, 12, 612], ["+", 15, 679, 31, 679, 12, 666, 0, 657, 12, 612], ["-", 0, 57, 15, 679, 12, 666, 0, 657, 12, 612], ["+", 0, 57, 15, 679, 12, 666, 0, 657, 12, 612]]
5
69
6
n = int(input()) for i in range(0, n): a = int(input()) b = int(input()) if a + b > 10 ** 80: print("overflow") elif a > 10 ** 80: print("overflow") elif b > 10 ** 80: print("overflow") else : print(a + b)
n = int(input()) for i in range(0, n): a = int(input()) b = int(input()) if a + b >= 10 ** 80: print("overflow") elif a >= 10 ** 80: print("overflow") elif b >= 10 ** 80: print("overflow") else : print(a + b)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["-", 8, 196, 0, 57, 75, 665, 15, 666, 667, 47], ["+", 8, 196, 0, 57, 75, 665, 15, 666, 667, 20]]
5
83
6
n = int(input()) for i in range(0, n): a = int(input()) b = int(input()) if len(str(a + b)) >= 80: print("overflow") elif len(str(a)) >= 80: print("overflow") elif len(str(b)) >= 80: print("overflow") else : print(a + b)
n = int(input()) for i in range(0, n): a = int(input()) b = int(input()) if len(str(a + b)) > 80: print("overflow") elif len(str(a)) > 80: print("overflow") elif len(str(b)) > 80: print("overflow") else : print(a + b)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["-", 8, 196, 0, 57, 75, 665, 15, 666, 667, 20], ["+", 8, 196, 0, 57, 75, 665, 15, 666, 667, 47]]
5
95
6
for _ in range(int(input())): a = int(input()) b = int(input()) s = a + b if s >= 1e79: print('overflow') else: print(s)
for _ in range(int(input())): a = int(input()) b = int(input()) s = a + b if s >= 10 ** 80: print('overflow') else: print(s)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 531], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 31, 612], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 578], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612]]
5
51
4
n = int(input()) for i in range(n): s = int(input())+int(input()) if len(str(s))>=80: print("overflow") else: print(s)
n = int(input()) for i in range(n): s = int(input())+int(input()) if len(str(s))>80: print("overflow") else: print(s)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47]]
5
54
2
# ?????¶??????????±???????????????°?????? import sys def main(): n = int(sys.stdin.readline().strip()) for _ in range(n): x = sys.stdin.readline().strip() y = sys.stdin.readline().strip() if len(x) > 80 or len(y) > 80: print('overflow') else: ans = int(x) + int(y) if len(str(ans)) > 80: print('overflow') else: print(x + y) if __name__ == '__main__': main()
# ?????¶??????????±???????????????°?????? import sys def main(): n = int(sys.stdin.readline().strip()) for _ in range(n): x = sys.stdin.readline().strip() y = sys.stdin.readline().strip() if len(x) > 80 or len(y) > 80: print('overflow') else: ans = int(x) + int(y) if len(str(ans)) > 80: print('overflow') else: print(ans) if __name__ == '__main__': main()
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]]
5
127
4
times=int(input()) for i in range(times): a=int(input()) b=int(input()) if len(str(a))<80 and len(str(b))<80 and len(str(a+b))<80: print(a+b) else: print("overflow")
times=int(input()) for i in range(times): a=int(input()) b=int(input()) if len(str(a))<=80 and len(str(b))<=80 and len(str(a+b))<=80: print(a+b) else: print("overflow")
[["-", 0, 57, 15, 679, 31, 679, 31, 666, 667, 18], ["+", 0, 57, 15, 679, 31, 679, 31, 666, 667, 19], ["-", 0, 57, 15, 679, 31, 679, 12, 666, 667, 18], ["+", 0, 57, 15, 679, 31, 679, 12, 666, 667, 19], ["-", 8, 196, 0, 57, 15, 679, 12, 666, 667, 18], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 19]]
5
79
6
upper = 10**81 n = int(input()) for i in range(n): n1 = int(input()) n2 = int(input()) if n1 >= upper or n2 >= upper: print("overflow") continue print( n1 + n2 if n1+n2 < upper else "overflow")
upper = 10**80 n = int(input()) for i in range(n): n1 = int(input()) n2 = int(input()) if n1 >= upper or n2 >= upper: print("overflow") continue print( n1 + n2 if n1+n2 < upper else "overflow")
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612]]
5
69
2
n=int(input()) for _ in range(n): a=int(input()) b=int(input()) ab=a+b print(ab if ab<=10**80 else "overflow")
n=int(input()) for _ in range(n): a=int(input()) b=int(input()) ab=a+b print(ab if ab<10**80 else "overflow")
[["-", 0, 652, 3, 4, 0, 41, 0, 666, 667, 19], ["+", 0, 652, 3, 4, 0, 41, 0, 666, 667, 18]]
5
51
2
for _ in range(int(input())): a=int(input())+int(input()) print([a,'overflow'][a>10**80])
for _ in range(int(input())): a=int(input())+int(input()) print(['overflow',a][a<10**80])
[["-", 0, 652, 3, 4, 0, 206, 51, 634, 0, 22], ["-", 0, 652, 3, 4, 0, 206, 51, 634, 0, 21], ["+", 0, 652, 3, 4, 0, 206, 51, 634, 0, 21], ["+", 0, 652, 3, 4, 0, 206, 51, 634, 0, 22], ["-", 0, 652, 3, 4, 0, 206, 206, 666, 667, 47], ["+", 0, 652, 3, 4, 0, 206, 206, 666, 667, 18]]
5
45
6
N=int(input()) A=[] B=[] for i in range(N): a = int(input()) b = int(input()) A.append(a) B.append(b) for i in range(N): if A[i] >= 10 ** 79 or B[i] >= 10 ** 79: print("overflow") elif A[i] + B[i]>= 10 ** 79: print("overflow") else: print(A[i]+B[i])
N = int(input()) A = [] B = [] for i in range(N): a = int(input()) b = int(input()) A.append(a) B.append(b) for i in range(N): if A[i] >= 10 ** 80 or B[i] >= 10 ** 80: print("overflow") elif A[i] + B[i] >= 10 ** 80: print("overflow") else: print(str(A[i] + B[i]))
[["-", 0, 57, 15, 679, 31, 666, 0, 657, 12, 612], ["+", 0, 57, 15, 679, 31, 666, 0, 657, 12, 612], ["-", 0, 57, 15, 679, 12, 666, 0, 657, 12, 612], ["+", 0, 57, 15, 679, 12, 666, 0, 657, 12, 612], ["-", 0, 57, 75, 665, 15, 666, 0, 657, 12, 612], ["+", 0, 57, 75, 665, 15, 666, 0, 657, 12, 612], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
120
9
N = int(input()) import re for _ in [0]*N: a = input().zfill(100) b = input().zfill(100) result = [] prev = 0 for i in range(1, 81): n = int(a[-i]) + int(b[-i]) + prev result.append(n%10) prev = n // 10 if prev > 0 or int(a[:21]) + int(b[:21]) > 0: print("overflow") else: result = "".join(map(str, result[::-1])) print(int(result))
N = int(input()) import re for _ in [0]*N: a = input().zfill(100) b = input().zfill(100) result = [] prev = 0 for i in range(1, 81): n = int(a[-i]) + int(b[-i]) + prev result.append(n%10) prev = n // 10 if prev > 0 or int(a[:-80]) + int(b[:-80]) > 0: print("overflow") else: result = "".join(map(str, result[::-1])) print(int(result))
[["-", 31, 652, 3, 4, 0, 206, 206, 663, 0, 612], ["+", 3, 4, 0, 206, 206, 663, 0, 664, 17, 33], ["+", 3, 4, 0, 206, 206, 663, 0, 664, 28, 612], ["-", 12, 652, 3, 4, 0, 206, 206, 663, 0, 612]]
5
150
6
if __name__ == '__main__': n = (int)(input()) for _ in range(n): sNumber = (int)(input()) tNumber = (int)(input()) uNumber = sNumber+tNumber print("over flow" if uNumber >= 10**80 else uNumber)
if __name__ == '__main__': n = (int)(input()) for _ in range(n): sNumber = (int)(input()) tNumber = (int)(input()) uNumber = sNumber+tNumber print("overflow" if uNumber >= 10**80 else uNumber)
[["-", 0, 652, 3, 4, 0, 41, 0, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 41, 0, 557, 0, 6]]
5
64
2
n = int(input()) for i in range(0,n): #a,b=map(int,raw_input().splitlines()) a = int(input()) b = int(input()) sum = a+b if len(str(sum)) < 80: print(sum) else: print("overflow")
n = int(input()) for i in range(0,n): #a,b=map(int,raw_input().splitlines()) a = int(input()) b = int(input()) sum = a+b if len(str(sum)) <= 80: print(sum) else: print("overflow")
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19]]
5
63
2
n = int(input()) for i in range(n): x = int(input()) y = int(input()) ans = x + y if(ans <= 10**80): print(ans) else: print("overflow")
n = int(input()) for i in range(n): x = int(input()) y = int(input()) ans = x + y if(ans < 10**80): print(ans) else: print("overflow")
[["-", 8, 196, 0, 57, 15, 23, 0, 666, 667, 19], ["+", 8, 196, 0, 57, 15, 23, 0, 666, 667, 18]]
5
58
2
n = int(input()) for i in range(0, n): x = int(input()) y = int(input()) sum = str(x+y) if len(sum) >= 80: print('overflow') else: print(sum)
n = int(input()) for i in range(0, n): x = int(input()) y = int(input()) sum = str(x+y) if len(sum) > 80: print('overflow') else: print(sum)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47]]
5
62
2
n=eval(input()) for i in range(n): a=eval(input()) b=eval(input()) if str(a+b)>80: print(overflow) else: print(a+b)
n=eval(input()) for i in range(n): a=eval(input()) b=eval(input()) if len(str(a+b))>80: print("overflow") else: print(a+b)
[["+", 8, 196, 0, 57, 15, 666, 0, 652, 63, 22], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655]]
5
54
5
from __future__ import (absolute_import, division, print_function, unicode_literals) from sys import stdin n = int(stdin.readline()) while n: result = int(stdin.readline()) + int(stdin.readline()) if len(str(result)) >= 80: print('overflow') else: print(result) n -= 1
from __future__ import (absolute_import, division, print_function, unicode_literals) from sys import stdin n = int(stdin.readline()) while n: result = int(stdin.readline()) + int(stdin.readline()) if len(str(result)) >= 81: print('overflow') else: print(result) n -= 1
[["-", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612]]
5
74
2
for val in range(0,eval(input())): a = eval(input()) b = eval(input()) c = a+b if len(str(a)) > 80 and len(str(b)) > 80 and len(str(c)) > 80: print(c) else: print('overflow')
for val in range(0,eval(input())): a = eval(input()) b = eval(input()) c = a+b if len(str(a)) <= 80 and len(str(b)) <= 80 and len(str(c)) <= 80: print(c) else: print('overflow')
[["-", 0, 57, 15, 679, 31, 679, 31, 666, 667, 47], ["+", 0, 57, 15, 679, 31, 679, 31, 666, 667, 19], ["-", 0, 57, 15, 679, 31, 679, 12, 666, 667, 47], ["+", 0, 57, 15, 679, 31, 679, 12, 666, 667, 19], ["-", 8, 196, 0, 57, 15, 679, 12, 666, 667, 47], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 19]]
5
79
6
n = int(input()) for i in range(0,n): a = int(input()) b = int(input()) ans = str(a+b) if len(ans) > 80: print('overflow') else: print(sum)
n = int(input()) for i in range(0,n): a = int(input()) b = int(input()) ans = str(a+b) if len(ans) > 80: print('overflow') else: print(ans)
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]]
5
62
2
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { int len, angle; int sum_ang = 90; // start double x = 0.0, y = 0.0; // ang(+) -> right while (scanf("%d,%d", &len, &angle), len != 0 && angle != 0) { x += len * cos(M_PI * sum_ang / 180.0); y += len * sin(M_PI * sum_ang / 180.0); sum_ang = (sum_ang - angle + 360) % 360; } printf("%d\n", (int)x); printf("%d\n", (int)y); return (0); }
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { int len, angle; int sum_ang = 90; // start double x = 0.0, y = 0.0; // ang(+) -> right while (scanf("%d,%d", &len, &angle), len != 0 || angle != 0) { x += len * cos(M_PI * sum_ang / 180.0); y += len * sin(M_PI * sum_ang / 180.0); sum_ang = (sum_ang - angle + 360) % 360; } printf("%d\n", (int)x); printf("%d\n", (int)y); return (0); }
[["-", 0, 52, 15, 339, 51, 34, 12, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 106]]
1
131
2
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #define PI 3.1415926535897932384626433 using namespace std; int main() { double nowx = 0, nowy = 0, nowkaku = PI / 2; while (1) { double ho, kaku; scanf("%lf,%lf", &ho, &kaku); if (ho == 0 && kaku == 0) break; nowy += sin(nowkaku) * ho; nowx += cos(nowkaku) * ho; nowkaku += PI / 180 * kaku; } printf("%d\n%d\n", (int)nowx, (int)nowy); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #define PI 3.1415926535897932384626433 using namespace std; int main() { double nowx = 0, nowy = 0, nowkaku = PI / 2; while (1) { double ho, kaku; scanf("%lf,%lf", &ho, &kaku); if (ho == 0 && kaku == 0) break; nowy += sin(nowkaku) * ho; nowx += cos(nowkaku) * ho; nowkaku += PI / 180 * kaku; } printf("%d\n%d\n", (int)nowx * -1, (int)nowy); return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 48], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
121
2
#include <cmath> #include <iostream> #define PI 3.14159265359 using namespace std; int main() { int d, a = 90, a2; double x, y; char c; while (cin >> d >> c >> a2) { if (d == 0 && a == 0) break; double rad = a * (PI / 180); x += d * cos(rad); y += d * sin(rad); a += a2; } cout << (int)x << "\n" << (int)y << endl; }
#include <cmath> #include <iostream> #define PI 3.14159265359 using namespace std; int main() { int d, a = 90, a2; double x, y; char c; while (cin >> d >> c >> a2) { if (d == 0 && a == 0) break; else { double rad = a * (PI / 180.0); x += d * cos(rad); y += d * sin(rad); a += a2; } } cout << -(int)x << "\n" << (int)y << endl; }
[["+", 0, 52, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["-", 49, 50, 51, 16, 12, 23, 0, 16, 12, 13], ["+", 49, 50, 51, 16, 12, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46], ["+", 31, 16, 31, 16, 31, 16, 12, 91, 17, 33]]
1
109
6
#include <cmath> #include <cstdio> #include <iostream> const double PI = 3.14159265359; using namespace std; int main() { double x = 0.0, y = 0.0; int d, a; int ca = 90; //???????????????????????? scanf("%d,%d", &d, &a); do { x += d * cos(ca / 180.0 * PI); y += d * sin(ca / 180.0 * PI); ca += a; scanf("%d,%d", &d, &a); } while (d != 0 || a != 0); cout << static_cast<int>(x) << endl << static_cast<int>(y); return 0; }
#include <cmath> #include <cstdio> #include <iostream> const double PI = 3.14159265359; using namespace std; int main() { double x = 0.0, y = 0.0; int d, a; int ca = 90; //???????????????????????? scanf("%d,%d", &d, &a); do { x += d * cos(ca / 180.0 * PI); y += d * sin(ca / 180.0 * PI); ca -= a; scanf("%d,%d", &d, &a); } while (d != 0 || a != 0); cout << static_cast<int>(x) << endl << static_cast<int>(y) << endl; return 0; }
[["-", 0, 82, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 82, 8, 9, 0, 1, 0, 11, 17, 110], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22]]
1
135
4
#include <bits/stdc++.h> using namespace std; #define FOR(i, l, r) for (int i = (l); i < (r); i++) #define ALL(x) (x).begin(), (x).end() template <typename T> bool chmax(T &a, const T &b) { return a < b ? (a = b, true) : false; } template <typename T> bool chmin(T &a, const T &b) { return b < a ? (a = b, true) : false; } typedef long long ll; const double PI = acos(-1.0); int main() { double X = 0.0, Y = 0.0; int A, B, R = 90; while (scanf("%d,%d", &A, &B) && A && B) { X += A * cos(R * PI / 180.0); Y += A * sin(R * PI / 180.0); R -= B; if (R > 180) R -= 360; if (R < -180) R += 360; } printf("%d\n%d\n", (int)X, (int)Y); return 0; }
#include <bits/stdc++.h> using namespace std; #define FOR(i, l, r) for (int i = (l); i < (r); i++) #define ALL(x) (x).begin(), (x).end() template <typename T> bool chmax(T &a, const T &b) { return a < b ? (a = b, true) : false; } template <typename T> bool chmin(T &a, const T &b) { return b < a ? (a = b, true) : false; } typedef long long ll; const double PI = acos(-1.0); int main() { double X = 0.0, Y = 0.0; int A, B, R = 90; while (scanf("%d,%d", &A, &B), (A || B)) { X += A * cos(R * PI / 180.0); Y += A * sin(R * PI / 180.0); R -= B; if (R > 180) R -= 360; if (R < -180) R += 360; } printf("%d\n%d\n", (int)X, (int)Y); return 0; }
[["-", 0, 52, 15, 339, 51, 16, 31, 16, 17, 98], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 0, 52, 15, 339, 51, 34, 12, 23, 0, 24], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 15, 339, 51, 34, 12, 23, 0, 16, 17, 106], ["+", 0, 52, 15, 339, 51, 34, 12, 23, 0, 25]]
1
222
6
#include <iostream> #include <math.h> #include <stdio.h> using namespace std; int main() { double sum, x, y, b, c; int a, d; a = 0; x = 0; y = 0; sum = 0; while (scanf("%d,%d", &d, &a)) { if (a == 0 && d == 0) break; b = (double)a; c = (double)d; x += c * cos(sum * 3.1416 / 180); y += c * sin(sum * 3.1416 / 180); sum += b; } cout << (int)y << " " << (int)x << endl; return 0; }
#include <iostream> #include <math.h> #include <stdio.h> using namespace std; int main() { double sum, x, y, b, c; int a, d; a = 0; x = 0; y = 0; sum = 0; while (scanf("%d,%d", &d, &a)) { if (a == 0 && d == 0) break; b = (double)a; c = (double)d; x += c * cos(sum * 3.1416 / 180); y += c * sin(sum * 3.1416 / 180); sum += b; } cout << (int)y << endl; cout << (int)x << endl; return 0; }
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22]]
1
142
6
#include <bits/stdc++.h> using namespace std; int main() { double x = 0, y = 0, s = 90, a, b; while (scanf("%f,%f", &a, &b), a) { x += a * cos(s * M_PI / 180); y += a * sin(s * M_PI / 180); s -= b; } cout << (int)x << endl; cout << (int)y << endl; }
#include <bits/stdc++.h> using namespace std; int main() { double x = 0, y = 0, s = 90; int a, b; while (scanf("%d,%d", &a, &b), a) { x += a * cos(s * M_PI / 180); y += a * sin(s * M_PI / 180); s -= b; } cout << (int)x << endl; cout << (int)y << endl; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 51, 34, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 51, 34, 31, 2, 3, 4, 0, 5, 0, 6]]
1
96
5
// C++14 (Clang 3.8.0) #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<long long, long long> P; double pi = 3.14159265358; int main() { double now = 90; double x = 0.0, y = 0.0; while (1) { double a, b; scanf("%lf,%lf", &a, &b); if (a == 0.0 and b == 0.0) break; double xx = 0.0, yy = 0.0; xx = cos(now / 180 * pi) * a; yy = sin(now / 180 * pi) * a; x += xx; y += yy; now -= (b); } printf("%d %d\n", (int)x, (int)y); }
// C++14 (Clang 3.8.0) #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<long long, long long> P; double pi = 3.14159265358; int main() { double now = 90; double x = 0.0, y = 0.0; while (1) { double a, b; scanf("%lf,%lf", &a, &b); if (a == 0.0 and b == 0.0) break; double xx = 0.0, yy = 0.0; xx = cos(now / 180 * pi) * a; yy = sin(now / 180 * pi) * a; x += xx; y += yy; now -= (b); } printf("%d\n%d\n", (int)x, (int)y); }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
191
4
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define dump(n) cout << "# " << #n << "=" << (n) << endl #define debug(n) \ cout << __FILE__ << "," << __LINE__ << ": #" << #n << "=" << (n) << endl #define repi(i, a, b) for (int i = int(a); i < int(b); i++) #define rep(i, n) repi(i, 0, n) #define iter(c) __typeof((c).begin()) #define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); i++) #define allof(c) (c).begin(), (c).end() #define mp make_pair typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int, int> pii; int main() { const double EPS = 1e-6; double x = 0, y = 0; double dir = M_PI / 2; for (int a, d; scanf("%d,%d", &a, &d), a | d;) { x += a * cos(dir); y += a * sin(dir); dir -= d * M_PI / 180; } printf("%d %d\n", int(x + EPS), int(y + EPS)); return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; #define dump(n) cout << "# " << #n << "=" << (n) << endl #define debug(n) \ cout << __FILE__ << "," << __LINE__ << ": #" << #n << "=" << (n) << endl #define repi(i, a, b) for (int i = int(a); i < int(b); i++) #define rep(i, n) repi(i, 0, n) #define iter(c) __typeof((c).begin()) #define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); i++) #define allof(c) (c).begin(), (c).end() #define mp make_pair typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int, int> pii; int main() { const double EPS = 1e-10; double x = 0, y = 0; double dir = M_PI / 2; for (int a, d; scanf("%d,%d", &a, &d), a | d;) { x += a * cos(dir); y += a * sin(dir); dir -= d * M_PI / 180; } printf("%d\n%d\n", int(x + EPS), int(y + EPS)); return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
237
6
#include <cmath> #include <cstdio> #include <iostream> #define R (3.1415926535898 / 180.0) using namespace std; int main() { int go, turn; double x = 0, y = 0, cur = 0; while (scanf("%d,%d\n", &go, &turn), (go && turn)) { y += cos(cur * R) * go; x += sin(cur * R) * go; cur += turn; } cout << (int)x << endl << (int)y << endl; }
#include <cmath> #include <cstdio> #include <iostream> #define R (3.1415926535898 / 180.0) using namespace std; int main() { int go, turn; double x = 0, y = 0, cur = 0; while (scanf("%d,%d\n", &go, &turn), (go || turn)) { y += cos(cur * R) * go; x += sin(cur * R) * go; cur += turn; } cout << (int)x << endl << (int)y << endl; }
[["-", 15, 339, 51, 34, 12, 23, 0, 16, 17, 98], ["+", 15, 339, 51, 34, 12, 23, 0, 16, 17, 106]]
1
103
2
#include <iostream> #include <math.h> using namespace std; int main() { double x = 0, y = 0; int degree = 90; double t; int d; char c; double pi = 3.141592; while (true) { cin >> t; x += t * cos(degree * pi / 180); y += t * sin(degree * pi / 180); cin >> c; cin >> d; degree += d; if (t == 0 && d == 0) break; } cout << (int)x << endl; cout << (int)y << endl; x = 0, y = 0; return 0; }
#include <iostream> #include <math.h> using namespace std; int main() { double x = 0, y = 0; int degree = 90; double t; int d; char c; double pi = 3.141592; while (true) { cin >> t; x += t * cos(degree * pi / 180); y += t * sin(degree * pi / 180); cin >> c; cin >> d; degree += d; if (t == 0 && d == 0) break; } cout << -(int)x << endl; cout << (int)y << endl; x = 0, y = 0; return 0; }
[["+", 0, 1, 0, 16, 31, 16, 12, 91, 17, 33]]
1
131
1
#include <cmath> #include <iostream> #include <stdio.h> using namespace std; int main() { double x = 0; double y = 0; double angle = 0; double r, th; while (1) { scanf("%lf,%lf", &r, &th); if (r == 0 && th == 0) break; x += r * sin(M_PI * angle / 90); y += r * cos(M_PI * angle / 90); angle += th; } printf("%d\n%d\n", (int)x, (int)y); return 0; }
#include <cmath> #include <iostream> #include <stdio.h> using namespace std; int main() { double x = 0; double y = 0; double angle = 0; double r, th; while (1) { scanf("%lf,%lf", &r, &th); if (r == 0 && th == 0) break; x += r * sin(2 * M_PI * angle / 360); y += r * cos(2 * M_PI * angle / 360); angle += th; } printf("%d\n%d\n", (int)x, (int)y); return 0; }
[["+", 3, 4, 0, 16, 31, 16, 31, 16, 31, 13], ["+", 3, 4, 0, 16, 31, 16, 31, 16, 17, 48], ["-", 12, 16, 12, 2, 3, 4, 0, 16, 12, 13], ["+", 12, 16, 12, 2, 3, 4, 0, 16, 12, 13]]
1
120
8
#include <cmath> #include <cstdio> using namespace std; int main() { int r, d, sd = 90; double x = 0.0, y = 0.0; while (scanf("%d,%d", &r, &d) == 2 && r != 0 && d != 0) { x += r * cos(sd * 3.141592 / 180.0); y += r * sin(sd * 3.141592 / 180.0); sd -= d; if (sd > 180) sd -= 360; else if (sd < -180) sd += 360; } printf("%d\n%d\n", (int)x, (int)y); return 0; }
#include <cmath> #include <cstdio> using namespace std; int main() { int r, d, sd = 90; double x = 0.0, y = 0.0; while (scanf("%d,%d", &r, &d) == 2 && !(r == 0 && d == 0)) { x += r * cos(sd * 3.141592 / 180.0); y += r * sin(sd * 3.141592 / 180.0); sd -= d; if (sd > 180) sd -= 360; else if (sd < -180) sd += 360; } printf("%d\n%d\n", (int)x, (int)y); return 0; }
[["+", 0, 52, 15, 339, 51, 16, 12, 91, 17, 111], ["+", 15, 339, 51, 16, 12, 91, 28, 23, 0, 24], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 79], ["+", 12, 91, 28, 23, 0, 16, 31, 16, 17, 60], ["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 12, 91, 28, 23, 0, 16, 12, 16, 17, 60], ["+", 15, 339, 51, 16, 12, 91, 28, 23, 0, 25]]
1
133
7
#include <cmath> #include <cstdlib> #include <iostream> #include <string> #define PI 3.141592653589793 using namespace std; int main() { string str; int to; double x, y, direction, r, theta; x = 0; y = 0; r = 0; theta = 0; direction = 90; while (cin >> str) { to = str.find(",", 0); r = (double)strtol(str.substr(0, to).c_str(), NULL, 10); theta = strtol(str.substr(to + 1).c_str(), NULL, 10); if (r == 0 && theta == 0) break; // cout << direction << endl; x += r * cos(direction * (PI / 180.0)); y += r * sin(direction * (PI / 180.0)); direction -= (double)theta; str = "0"; } cout << x << endl << y << endl; }
#include <cmath> #include <cstdlib> #include <iostream> #include <string> #define PI 3.141592653589793 using namespace std; int main() { string str; int to; double x, y, direction, r, theta; x = 0; y = 0; r = 0; theta = 0; direction = 90; while (cin >> str) { to = str.find(",", 0); r = (double)strtol(str.substr(0, to).c_str(), NULL, 10); theta = strtol(str.substr(to + 1).c_str(), NULL, 10); if (r == 0 && theta == 0) break; // cout << direction << endl; x += r * cos(direction * (PI / 180.0)); y += r * sin(direction * (PI / 180.0)); direction -= (double)theta; str = "0"; } cout << (int)x << endl << (int)y << endl; }
[["+", 31, 16, 31, 16, 31, 16, 12, 74, 0, 24], ["+", 31, 16, 31, 16, 12, 74, 39, 77, 39, 40], ["+", 31, 16, 31, 16, 31, 16, 12, 74, 0, 25], ["+", 0, 1, 0, 16, 31, 16, 12, 74, 0, 24], ["+", 0, 16, 31, 16, 12, 74, 39, 77, 39, 40], ["+", 0, 1, 0, 16, 31, 16, 12, 74, 0, 25]]
1
192
6
// 0016 // Time-stamp: <2012-07-10 18:47:25 naga> #include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #define PI 3.1415926535 using namespace std; int main() { int walk, deg; double x, y; int direction; x = y = 0; direction = 90; while (true) { // radian = (double)(direction * PI/ 180); scanf("%d,%d", &walk, &deg); if (!walk && !deg) { break; } x += (double)walk * cos(direction * PI / 180); y += (double)walk * sin(direction * PI / 180); // 向きを変える。角度を360以下に direction += deg; if (direction > 360) { direction = direction - 360; } } cout << (int)x << endl << (int)y << endl; return 0; }
// 0016 // Time-stamp: <2012-07-10 18:48:35 naga> #include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #define PI 3.1415926535 using namespace std; int main() { int walk, deg; double x, y; int direction; x = y = 0; direction = 90; while (true) { // radian = (double)(direction * PI/ 180); scanf("%d,%d", &walk, &deg); if (!walk && !deg) { break; } x += (double)walk * cos(direction * PI / 180); y += (double)walk * sin(direction * PI / 180); // 向きを変える。角度を360以下に direction += deg; if (direction > 360) { direction = direction - 360; } } cout << (int)-x << endl << (int)y << endl; return 0; }
[["+", 31, 16, 31, 16, 12, 74, 51, 91, 17, 33]]
1
148
1
#include <cmath> #include <cstdio> double rad = 90.00000000000; //回転角 double x = 0.0, y = 0.0; //現在地 int answer_x, answer_y; double PI = 6 * asin(0.5) / 180; int main() { int a, b; while (scanf("%d,%d", &a, &b) != EOF) { if (a == 0 && b == 0) break; y += sin(rad * PI) * a; x += cos(rad * PI) * a; rad = (rad - b); } if (x > 0) answer_x = floor(x); else answer_x = ceil(x); if (y > 0) answer_y = floor(y); else answer_y = ceil(y); printf("%d %d\n", answer_x, answer_y); return 0; }
#include <cmath> #include <cstdio> double rad = 90.00000000000; //回転角 double x = 0.0, y = 0.0; //現在地 int answer_x, answer_y; double PI = 6 * asin(0.5) / 180; int main() { int a, b; while (scanf("%d,%d", &a, &b) != EOF) { if (a == 0 && b == 0) break; y += sin(rad * PI) * a; x += cos(rad * PI) * a; rad = (rad - b); } if (x > 0) answer_x = floor(x); else answer_x = ceil(x); if (y > 0) answer_y = floor(y); else answer_y = ceil(y); printf("%d\n%d\n", answer_x, answer_y); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
166
4
#include <cmath> #include <cstdio> #define PI 3.14159265358979323 int correct(int d) { if (d < 0) { return d + 360; } else if (d > 360) { return d - 360; } else { return d; } } int main() { double x = 0, y = 0; int l, d, dir = -90; while (scanf("%d,%d", &l, &d), l) { x += l * cos(PI * dir / 180); y += l * sin(PI * dir / 180); dir = correct(dir + d); } printf("%d\n%d\n", (int)x, (int)y); }
#include <cmath> #include <cstdio> #define PI 3.14159265358979323846 int correct(int d) { if (d < 0) { return d + 360; } else if (d > 360) { return d - 360; } else { return d; } } int main() { double x = 0, y = 0; int l, d, dir = 0; while (scanf("%d,%d", &l, &d), l) { x += l * sin(PI * dir / 180); y += l * cos(PI * dir / 180); dir = correct(dir + d); } printf("%d\n%d\n", (int)x, (int)y); }
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 1, 0, 11, 12, 16, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 2, 63, 22]]
1
146
8
#include <math.h> #include <stdio.h> double na; double nx, ny; int main() { int d; int a; na = 90; nx = 0; ny = 0; while (1) { scanf("%d,%d", &d, &a); if (d == 0 && a == 0) break; nx += (double)d * cos(M_PI * na / 180); ny += (double)d * sin(M_PI * na / 180); na -= a; } printf("%d %d\n", (int)nx, (int)ny); }
#include <math.h> #include <stdio.h> double na; double nx, ny; int main() { int d; int a; na = 90; nx = 0; ny = 0; while (1) { scanf("%d,%d", &d, &a); if (d == 0 && a == 0) break; nx += (double)d * cos(M_PI * na / 180); ny += (double)d * sin(M_PI * na / 180); na -= a; } printf("%d\n%d\n", (int)nx, (int)ny); }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
121
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <stack> #include <string> #include <vector> #define INIT_DIR 90 #define PI 3.141592 using namespace std; int main() { double dir = INIT_DIR * PI / 180; double moveX = 0, moveY = 0; int mx = 0, my = 0; string tmp; int tp = 0, tp2 = 0; char copy[8]; while (cin >> tmp) { strcpy(copy, tmp.c_str()); tp = atoi(strtok(copy, ",")); tp2 = atoi(strtok(NULL, ",")); if (tp == 0 && tp2 == 0) { break; } moveX += tp * cos(dir); moveY += tp * sin(dir); dir += tp2 * PI / 180; } mx = (int)moveX; my = (int)moveY; cout << mx << endl << my << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <stack> #include <string> #include <vector> #define INIT_DIR 90 #define PI 3.141592 using namespace std; int main() { double dir = INIT_DIR * PI / 180; double moveX = 0, moveY = 0; int mx = 0, my = 0; string tmp; int tp = 0, tp2 = 0; char copy[8]; while (cin >> tmp) { strcpy(copy, tmp.c_str()); tp = atoi(strtok(copy, ",")); tp2 = atoi(strtok(NULL, ",")); if (tp == 0 && tp2 == 0) { break; } moveX += tp * cos(dir); moveY += tp * sin(dir); dir += tp2 * PI / 180; } mx = (int)moveX * -1; my = (int)moveY; cout << mx << endl << my << endl; return 0; }
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
199
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <stack> #include <string> #include <vector> #define INIT_DIR 90 #define PI 3.141592 using namespace std; int main() { double dir = INIT_DIR * PI / 180; double moveX = 0, moveY = 0; int mx = 0, my = 0; string tmp; int tp = 0, tp2 = 0; char copy[8]; while (cin >> tmp) { strcpy(copy, tmp.c_str()); tp = atoi(strtok(copy, ",")); tp2 = atoi(strtok(NULL, ",")); if (tp == 0 && tp2 == 0) { break; } moveX += tp * cos(dir); moveY += tp * sin(dir); dir += tp2 * PI / 180; } mx = (int)moveX; my = (int)moveY; cout << mx << endl << my << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <stack> #include <string> #include <vector> #define INIT_DIR 90 #define PI 3.141592 using namespace std; int main() { double dir = INIT_DIR * PI / 180; double moveX = 0, moveY = 0; int mx = 0, my = 0; string tmp; int tp = 0, tp2 = 0; char copy[8]; while (cin >> tmp) { strcpy(copy, tmp.c_str()); tp = atoi(strtok(copy, ",")); tp2 = atoi(strtok(NULL, ",")); if (tp == 0 && tp2 == 0) { break; } moveX += tp * cos(dir); moveY += tp * sin(dir); dir += (tp2 * PI / 180) * -1; } mx = (int)moveX; my = (int)moveY; cout << mx << endl << my << endl; return 0; }
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
199
4
#include <cmath> #include <iostream> using namespace std; int main() { int i, j; char c; double x, y, a, pi = 3.1415926; x = y = 0; a = 90 * pi / 180; while (1) { cin >> i >> c >> j; if (i == 0 && j == 0) break; x += i * cos(a); y += i * sin(a); a += j * pi / 180; } cout << trunc(x) << endl; cout << trunc(y) << endl; return 0; }
#include <cmath> #include <iostream> using namespace std; int main() { int i, j; char c; double x, y, a, pi = 3.1415926; x = y = 0; a = 90 * pi / 180; while (1) { cin >> i >> c >> j; if (i == 0 && j == 0) break; x += i * cos(a); y += i * sin(a); a -= j * pi / 180; } cout << trunc(x) << endl; cout << trunc(y) << endl; return 0; }
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 110]]
1
120
2
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { double ln, cta, x = 0, y = 0, angle = 90.0; while (1) { scanf("%lf,%lf", &ln, &cta); if (ln == 0 && cta == 0) break; x += ln * cos((angle / 180) * M_PI); y += ln * sin((angle / 180) * M_PI); angle -= cta; } cout << x << "\n" << y << endl; return 0; }
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { double ln, cta, x = 0, y = 0, angle = 90.0; while (1) { scanf("%lf,%lf", &ln, &cta); if (ln == 0 && cta == 0) break; x += ln * cos((angle / 180) * M_PI); y += ln * sin((angle / 180) * M_PI); angle -= cta; } cout << (int)x << "\n" << (int)y << endl; return 0; }
[["+", 31, 16, 31, 16, 31, 16, 12, 74, 0, 24], ["+", 31, 16, 31, 16, 12, 74, 39, 77, 39, 40], ["+", 31, 16, 31, 16, 31, 16, 12, 74, 0, 25], ["+", 0, 1, 0, 16, 31, 16, 12, 74, 0, 24], ["+", 0, 16, 31, 16, 12, 74, 39, 77, 39, 40], ["+", 0, 1, 0, 16, 31, 16, 12, 74, 0, 25]]
1
113
6
#include <cmath> #include <iostream> #define PI acos(-1) using namespace std; int main() { double x = 0.0, y = 0.0; double nr = PI / 2.0; int l, r; while (true) { cin >> l; cin.ignore(); cin >> r; if (!(l | r)) break; x += l * cos(nr); y += l * sin(nr); nr -= r * PI / 180.0; } cout << (int)x << ' ' << (int)y << endl; return 0; }
#include <cmath> #include <iostream> #define PI acos(-1) using namespace std; int main() { double x = 0.0, y = 0.0; double nr = PI / 2.0; int l, r; while (true) { cin >> l; cin.ignore(); cin >> r; if (!(l | r)) break; x += l * cos(nr); y += l * sin(nr); nr -= r * PI / 180.0; } cout << (int)x << endl << (int)y << endl; return 0; }
[["-", 0, 16, 31, 16, 31, 16, 12, 103, 0, 104], ["-", 0, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["+", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22]]
1
116
4
#include <math.h> #include <stdio.h> #define M_PI 3.14159265358979 int main(void) { int i = 0, a, b, k = 90; double x = 0, y = 0; while (i == 0) { scanf("%d,%d", &a, &b); if (a == 0 || b == 0) break; x += cos(k * M_PI / 180) * a; y += sin(k * M_PI / 180) * a; k -= b; } printf("%d\n", (int)x); printf("%d\n", (int)y); return 0; }
#include <math.h> #include <stdio.h> #define M_PI 3.14159265358979 int main(void) { int i = 0, a, b, k = 90; double x = 0, y = 0; while (i == 0) { scanf("%d,%d", &a, &b); if (a == 0 && b == 0) break; x += cos(k * M_PI / 180) * a; y += sin(k * M_PI / 180) * a; k -= b; } printf("%d\n", (int)x); printf("%d\n", (int)y); return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98]]
1
128
2
#include <cmath> #include <iostream> using namespace std; double x, y, dir = M_PI / 2.0; int a, b; char c; int main() { x = y = 0.0; while (cin >> a >> c >> b && a) { x -= cos(dir) * (double)a; y += sin(dir) * (double)a; dir += b / 180.0 * M_PI; while (dir >= 2.0 * M_PI) dir -= 2.0 * M_PI; while (dir < 0.0) dir += 2.0 * M_PI; } cout << (int)x << ' ' << (int)y << endl; return 0; }
#include <cmath> #include <iostream> using namespace std; double x, y, dir = M_PI / 2.0; int a, b; char c; int main() { x = y = 0.0; while (cin >> a >> c >> b && a) { x -= cos(dir) * (double)a; y += sin(dir) * (double)a; dir += b / 180.0 * M_PI; while (dir >= 2.0 * M_PI) dir -= 2.0 * M_PI; while (dir < 0.0) dir += 2.0 * M_PI; } cout << (int)x << endl << (int)y << endl; return 0; }
[["-", 0, 16, 31, 16, 31, 16, 12, 103, 0, 104], ["-", 0, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["+", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22]]
1
132
4
#include <cmath> #include <cstdio> #include <iostream> #include <vector> using namespace std; #define X 0 #define Y 1 #define PI 3.141592653589 int main() { vector<double> udv = {0, 1}; // 単位方向ベクトル vector<double> cur_position = {0, 0}; int step = 0, angle = 0; while (1) { scanf("%d,%d", &step, &angle); if (!step && !angle) break; cur_position.at(X) += udv.at(X) * step; cur_position.at(Y) += udv.at(Y) * step; // rotation double x = cos(angle * PI / 180.0) * udv.at(X) + sin(angle * PI / 180.0) * udv.at(Y); double y = -sin(angle * PI / 180.0) * udv.at(X) + cos(angle * PI / 180.0) * udv.at(Y); udv.at(X) = x / sqrt(x * x + y * y); udv.at(Y) = y / sqrt(x * x + y * y); } cout << static_cast<int>(cur_position.at(X)) << " " << static_cast<int>(cur_position.at(Y)) << endl; return 0; }
#include <cmath> #include <cstdio> #include <iostream> #include <vector> using namespace std; #define X 0 #define Y 1 #define PI 3.141592653589 int main() { vector<double> udv = {0, 1}; // 単位方向ベクトル vector<double> cur_position = {0, 0}; int step = 0, angle = 0; while (1) { scanf("%d,%d", &step, &angle); if (!step && !angle) break; cur_position.at(X) += udv.at(X) * step; cur_position.at(Y) += udv.at(Y) * step; // rotation double x = cos(angle * PI / 180.0) * udv.at(X) + sin(angle * PI / 180.0) * udv.at(Y); double y = -sin(angle * PI / 180.0) * udv.at(X) + cos(angle * PI / 180.0) * udv.at(Y); udv.at(X) = x / sqrt(x * x + y * y); udv.at(Y) = y / sqrt(x * x + y * y); } cout << static_cast<int>(cur_position.at(X)) << endl << static_cast<int>(cur_position.at(Y)) << endl; return 0; }
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22]]
1
271
4
#include <cmath> #include <iostream> const double rad = (3.14159265 / 180); int main() { int m, angle, sumangle = 0; double x = 0, y = 0; char c; while (std::cin >> m >> c >> angle, m || angle) { x += (std::cos((90 - sumangle) * rad) * m); y += (std::sin((90 - sumangle) * rad) * m); sumangle += angle; } std::cout << (int)x << " " << (int)y << std::endl; return 0; }
#include <cmath> #include <iostream> const double rad = (3.14159265 / 180); int main() { int m, angle, sumangle = 0; double x = 0, y = 0; char c; while (std::cin >> m >> c >> angle, m || angle) { x += (std::cos((90 - sumangle) * rad) * m); y += (std::sin((90 - sumangle) * rad) * m); sumangle += angle; } std::cout << (int)x << std::endl << (int)y << std::endl; return 0; }
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 16, 31, 16, 31, 16, 12, 343, 345, 348], ["+", 0, 16, 31, 16, 31, 16, 12, 343, 0, 349], ["+", 0, 16, 31, 16, 31, 16, 12, 343, 141, 22]]
1
126
6
#define _USE_MATH_DEFINES #include <iostream> #include <math.h> #include <string> #include <vector> using namespace std; int main() { double x = 0, y = 0, r = 90; //初期設定 double d, rd; //入力値 更新部分 char c; //ごみ while (cin >> d >> c >> rd) { if (d == 0 && rd == 0) break; x += d * cos(r / 180 * M_PI); y += d * sin(r / 180 * M_PI); r -= rd; } cout << (int)x << " " << (int)y << endl; return 0; }
#define _USE_MATH_DEFINES #include <iostream> #include <math.h> #include <string> #include <vector> using namespace std; int main() { double x = 0, y = 0, r = 90; //初期設定 double d, rd; //入力値 更新部分 char c; //ごみ while (cin >> d >> c >> rd) { if (d == 0 && rd == 0) break; x += d * cos(r / 180 * M_PI); y += d * sin(r / 180 * M_PI); r -= rd; } cout << (int)x << endl; cout << (int)y << endl; return 0; }
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22]]
1
119
6
x = 0 y = 0 bd = 0 loop do step, dir = gets.chomp.split(',').map(&:to_i) break if step.zero? && dir.zero? rad = bd * Math::PI / 180 x += step * Math.cos(rad) y += step * Math.sin(rad) bd += dir end puts x.to_i puts y.to_i
x = 0 y = 0 bd = 0 loop do step, dir = gets.chomp.split(',').map(&:to_i) break if step.zero? && dir.zero? rad = bd * Math::PI / 180 x += step * Math.sin(rad) y += step * Math.cos(rad) bd += dir end puts x.to_i puts y.to_i
[["-", 8, 736, 0, 755, 12, 738, 12, 652, 735, 22], ["+", 8, 736, 0, 755, 12, 738, 12, 652, 735, 22]]
4
81
4
class TreasureHunter def initialize @x = 0 @y = 0 @deg = 0 end def to_rad(deg) return Math::PI * deg / 180.0 end def walk(distance) @x += Math.sin(to_rad(@deg)) * distance @y += Math.cos(to_rad(@deg)) * distance end def turn(direction) @deg += direction end def dumpXY return [@x.floor, @y.floor] end end t = TreasureHunter.new $<.each_line do |line| distance, direction = line.split(/,/).map(&:to_i) t.walk(distance) t.turn(direction) end puts t.dumpXY
class TreasureHunter def initialize @x = 0 @y = 0 @deg = 0 end def to_rad(deg) return Math::PI * deg / 180.0 end def walk(distance) @x += Math.sin(to_rad(@deg)) * distance @y += Math.cos(to_rad(@deg)) * distance end def turn(direction) @deg += direction end def dumpXY return [@x.to_i, @y.to_i] end end t = TreasureHunter.new $<.each_line do |line| distance, direction = line.split(/,/).map(&:to_i) t.walk(distance) t.turn(direction) end puts t.dumpXY
[["-", 0, 38, 0, 4, 0, 516, 0, 652, 735, 22], ["+", 0, 38, 0, 4, 0, 516, 0, 652, 735, 22]]
4
130
26
class Sambonmatsu def initialize @x = 0 @y = 0 @direct = 90 end def calc while(input = $stdin.gets) do direct, rotate = input.chomp.split(',').map(&:to_i) if direct == 0 && rotate == 0 break end step(direct) @direct -= rotate end puts @x.round puts @y.round end def step(direct) thita = (@direct/360.0)*2*Math::PI @x += direct*Math.cos(thita) @y += direct*Math.sin(thita) end end s = Sambonmatsu.new s.calc
class Sambonmatsu def initialize @x = 0 @y = 0 @direct = 90 end def calc while(input = $stdin.gets) do direct, rotate = input.chomp.split(',').map(&:to_i) if direct == 0 && rotate == 0 break end step(direct) @direct -= rotate end puts @x.truncate puts @y.truncate end def step(direct) thita = (@direct/360.0)*2*Math::PI @x += direct*Math.cos(thita) @y += direct*Math.sin(thita) end end s = Sambonmatsu.new s.calc
[["-", 8, 736, 0, 652, 3, 4, 0, 652, 735, 22], ["+", 8, 736, 0, 652, 3, 4, 0, 652, 735, 22]]
4
120
4
include Math x, y = 0, 0 s = 90 while true d, si = gets.chomp.split(",").map(&:to_i) break if d == 0 && si == 0 x += d * cos(2 * PI * s / 360) y += d * sin(2 * PI * s / 360) s += si end puts x.truncate puts y.truncate
include Math x, y = 0, 0 s = 90 while true d, si = gets.chomp.split(",").map(&:to_f) break if d == 0 && si == 0 x += d * cos(2 * PI * s / 360) y += d * sin(2 * PI * s / 360) s -= si end puts x.truncate puts y.truncate
[["-", 0, 662, 12, 652, 3, 4, 0, 752, 0, 753], ["+", 0, 662, 12, 652, 3, 4, 0, 752, 0, 753], ["-", 0, 493, 0, 89, 8, 170, 0, 755, 17, 107], ["+", 0, 493, 0, 89, 8, 170, 0, 755, 17, 110]]
4
83
4
include Math theta = 90.0 puts $<.to_a.map{|i|i.split(',')}.map{|i|i.map(&:to_i)}.collect{|a| ret = [a[0] * cos(theta*PI/180.0), a[0] * sin(theta*PI/180.0)] theta -= a[1] ret }.transpose.map{|i|i.inject(:+)}.join("\n")
include Math theta = 90.0 puts $<.to_a.map{|i|i.split(',')}.map{|i|i.map(&:to_i)}.collect{|a| ret = [a[0] * cos(theta*PI/180.0), a[0] * sin(theta*PI/180.0)] theta -= a[1] ret }.transpose.map{|i|i.inject(:+).to_i}.join("\n")
[["+", 486, 652, 196, 196, 8, 734, 0, 652, 17, 131], ["+", 486, 652, 196, 196, 8, 734, 0, 652, 735, 22]]
4
105
2
import math now_r=0 now_x=0 now_y=0 while True: n,r=list(map(int,input().split(","))) if n==0 and r==0: break now_x+=n*math.sin((now_r/180.0)*math.pi) now_y+=n*math.cos((now_r/180.0)*math.pi) now_r+=r print(math.floor(now_x)) print(math.floor(now_y))
import math now_r=0 now_x=0 now_y=0 while True: n,r=list(map(int,input().split(","))) if n==0 and r==0: break now_x+=n*math.sin((now_r/180.0)*math.pi) now_y+=n*math.cos((now_r/180.0)*math.pi) now_r+=r print(int(now_x)) print(int(now_y))
[["-", 0, 652, 3, 4, 0, 652, 63, 319, 500, 22], ["-", 0, 652, 3, 4, 0, 652, 63, 319, 0, 131], ["-", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22]]
5
103
8
import math x,y,r = 0,0,90 while True: m,n = map(int,raw_input().split(',')) if (m,n) == (0,0): break y += m * math.sin(math.radians(r)) y x+= m * math.cos(math.radians(r)) r -= n print(int(x)) print(int(y))
import math x,y,r = 0,0,90 while True: m,n = map(int,input().split(',')) if (m,n) == (0,0): break y += m * math.sin(math.radians(r)) x += m * math.cos(math.radians(r)) r -= n print(int(x)) print(int(y))
[["-", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22], ["+", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22], ["-", 0, 656, 0, 52, 8, 196, 0, 1, 0, 22]]
5
97
3
import math x, y, r = 0, 0, 90 while True: d, t = map(float, input().split(",")) if d == t == 0: break x += r * math.cos(math.radians(r)) y += r * math.sin(math.radians(r)) r -= t print(int(x)) print(int(y))
import math x, y, r = 0, 0, 90 while True: d, t = map(float, input().split(",")) if d == t == 0: break x += d * math.cos(math.radians(r)) y += d * math.sin(math.radians(r)) r -= t print(int(x)) print(int(y))
[["-", 8, 196, 0, 1, 0, 677, 12, 657, 31, 22], ["+", 8, 196, 0, 1, 0, 677, 12, 657, 31, 22]]
5
90
4
import math x = 0 y = 0 r = 90 while True: d,t=map(int, input().split()) if d==0 and t==0: print(int(x),int(y),sep='\n') exit() x += math.cos(math.radians(r)) * d y += math.sin(math.radians(r)) * d r -= t
import math x = 0 y = 0 r = 90 while True: d,t=map(int, input().split(',')) if d==0 and t==0: print(int(x),int(y),sep='\n') exit() x += math.cos(math.radians(r)) * d y += math.sin(math.radians(r)) * d r -= t
[["+", 3, 4, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 3, 4, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 3, 4, 0, 652, 3, 4, 0, 557, 0, 655]]
5
93
3
from math import * x , y = 0, 0 rad = radians(90) while True: d, t = list(map(int, input().split(','))) if d == 0: break x = x + cos(rad) * d y = y + sin(rad) * d rad -= radians(t) print(x) print(y)
from math import * x , y = 0, 0 rad = radians(90) while True: d, t = list(map(int, input().split(','))) if d == 0: break x = x + cos(rad) * d y = y + sin(rad) * d rad -= radians(t) print(int(x)) print(int(y))
[["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
5
82
6
import sys import math as mas x,y,d=0,0,90 for t in sys.stdin: a,b=map(int,t.split(',')) if a==b==0:break x+=a*mas.cos(mas.radians(d)) y+=a*mas.sin(mas.radians(d)) d-=b print(x) print(y) #for i in sys.stdin: # a,b=map(int,i.split()) # print(gcd(a,b),lcm(a,b))
import sys import math as mas x,y,d=0,0,90 for t in sys.stdin: a,b=map(int,t.split(',')) if a==b==0:break x+=a*mas.cos(mas.radians(d)) y+=a*mas.sin(mas.radians(d)) d-=b print(int(x)) print(int(y)) #for i in sys.stdin: # a,b=map(int,i.split()) # print(gcd(a,b),lcm(a,b))
[["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
5
93
6
import sys import math def TreasureHunt(): x,y=(0.0,0.0) alpha=90 for line in sys.stdin: a,b=list(map(int,line.split(','))) if a==0 and b==0: break x+=a*math.cos(alpha/180.0*math.pi) y+=a*math.sin(alpha/180.0*math.pi) alpha=(alpha-b+360)%360 print(int(x),int(y)) TreasureHunt()
import sys import math def TreasureHunt(): x,y=(0.0,0.0) alpha=90 for line in sys.stdin: a,b=list(map(int,line.split(','))) if a==0 and b==0: break x+=a*math.cos(alpha/180.0*math.pi) y+=a*math.sin(alpha/180.0*math.pi) alpha=(alpha-b+360)%360 print(int(x)) print(int(y)) TreasureHunt()
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["+", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24]]
5
116
4
from math import cos, sin, pi treasure_x, treasure_y = 0, 0 angle = pi / 2 while True: d, a = map(int, input().split(',')) if d == 0 and a == 0: break treasure_x += d * cos(angle) treasure_y += d * sin(angle) angle += a * 2 * pi / 180 print(int(treasure_x)) print(int(treasure_y))
from math import cos, sin, pi treasure_x, treasure_y = 0, 0 angle = pi / 2 while True: d, a = map(int, input().split(',')) if d == 0 and a == 0: break treasure_x += d * cos(angle) treasure_y += d * sin(angle) angle -= a * pi / 180 print(int(treasure_x)) print(int(treasure_y))
[["-", 0, 52, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 52, 8, 196, 0, 1, 0, 677, 17, 110], ["-", 0, 677, 12, 657, 31, 657, 31, 657, 17, 48], ["-", 0, 677, 12, 657, 31, 657, 31, 657, 12, 612]]
5
91
4
#include <stdio.h> void swap(int A[], int a, int b) { int temp; temp = A[a]; A[a] = A[b]; A[b] = temp; return; } void bubblesort(int A[], int n) { int i, j; for (i = 0; i < 4; i++) { for (j = i + 1; j < 5; j++) { if (A[j] > A[j - 1]) swap(A, j, j - 1); } } return; } int main() { int n, i; int A[5]; for (i = 0; i < 5; i++) scanf("%d", &A[i]); bubblesort(A, 5); for (i = 0; i < 4; i++) printf("%d ", A[i]); printf("%d\n", A[4]); return 0; }
#include <stdio.h> void swap(int A[], int a, int b) { int temp; temp = A[a]; A[a] = A[b]; A[b] = temp; return; } void bubblesort(int A[], int n) { int i, j; for (i = 0; i < 4; i++) { for (j = 1; j < 5 - i; j++) { if (A[j] > A[j - 1]) swap(A, j, j - 1); } } return; } int main() { int n, i; int A[5]; for (i = 0; i < 5; i++) scanf("%d", &A[i]); bubblesort(A, 5); for (i = 0; i < 4; i++) printf("%d ", A[i]); printf("%d\n", A[4]); return 0; }
[["-", 8, 9, 0, 7, 10, 11, 12, 16, 31, 22], ["-", 8, 9, 0, 7, 10, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 22]]
0
215
4
a[5], e, x; main(t) { for (; e < 5;) scanf("%d", &a[e++]); for (e = 0; e < 4; e++) for (x = e + 1; x < 5; x++) if (a[e] < a[x]) t = a[e], a[e] = a[x], a[x] = t; for (e = 0; e < 5;) printf("%d", a[e++]), (e - 4) ? printf(" ") : puts(""); exit(0); }
a[5], e, x; main(t) { for (; e < 5;) scanf("%d", &a[e++]); for (e = 0; e < 4; e++) for (x = e + 1; x < 5; x++) if (a[e] < a[x]) t = a[e], a[e] = a[x], a[x] = t; for (e = 0; e < 5;) printf("%d", a[e++]), (e - 5) ? printf(" ") : puts(""); exit(0); }
[["-", 0, 34, 12, 41, 15, 23, 0, 16, 12, 13], ["+", 0, 34, 12, 41, 15, 23, 0, 16, 12, 13]]
0
149
2
#include <stdio.h> #include <stdlib.h> int compare_int(const void *a, const void *b); int main() { int a[5]; scanf("%d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4]); qsort(a, 5, sizeof(int), compare_int); printf("%d %d %d %d %d\n", a[0], a[1], a[2], a[3], a[4]); return 0; } int compare_int(const void *a, const void *b) { return *(int *)a - *(int *)b; }
#include <stdio.h> #include <stdlib.h> int compare_int(const void *a, const void *b); int main() { int a[5]; scanf("%d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4]); qsort(a, 5, sizeof(int), compare_int); printf("%d %d %d %d %d\n", a[0], a[1], a[2], a[3], a[4]); return 0; } int compare_int(const void *a, const void *b) { return *(int *)b - *(int *)a; }
[["-", 0, 37, 0, 16, 31, 66, 28, 74, 51, 22], ["+", 0, 37, 0, 16, 31, 66, 28, 74, 51, 22], ["-", 0, 37, 0, 16, 12, 66, 28, 74, 51, 22], ["+", 0, 37, 0, 16, 12, 66, 28, 74, 51, 22]]
0
147
4
#include <stdio.h> #include <stdlib.h> int cmp(const void *a, const void *b) { return (*(int *)a - *(int *)b); } int main() { int i, five[5]; scanf("%d %d %d %d %d", five, five + 1, five + 2, five + 3, five + 4); qsort(five, 5, sizeof(int), cmp); printf("%d %d %d %d %d\n", five[0], five[1], five[2], five[3], five[4]); return 0; }
#include <stdio.h> #include <stdlib.h> int cmp(const void *a, const void *b) { return (*(int *)b - *(int *)a); } int main() { int i, five[5]; scanf("%d %d %d %d %d", five, five + 1, five + 2, five + 3, five + 4); qsort(five, 5, sizeof(int), cmp); printf("%d %d %d %d %d\n", five[0], five[1], five[2], five[3], five[4]); return 0; }
[["-", 0, 23, 0, 16, 31, 66, 28, 74, 51, 22], ["+", 0, 23, 0, 16, 31, 66, 28, 74, 51, 22], ["-", 0, 23, 0, 16, 12, 66, 28, 74, 51, 22], ["+", 0, 23, 0, 16, 12, 66, 28, 74, 51, 22]]
0
125
4
#include <stdio.h> int main(void) { int a[5], i, j, k; int x = 0; scanf("%d%d%d%d%d", &a[0], &a[1], &a[2], &a[3], &a[4]); for (i = 0; i < 5; i++) { for (j = 0; j < 5; j++) { if (a[i] > a[j]) { x = a[i]; a[i] = a[j]; a[j] = x; } } } for (k = 0; k < 4; k++) { printf("%d ", a[k]); } printf("a[4]\n"); return 0; }
#include <stdio.h> int main(void) { int a[5], i, j, k; int x = 0; scanf("%d%d%d%d%d", &a[0], &a[1], &a[2], &a[3], &a[4]); for (i = 0; i < 5; i++) { for (j = 0; j < 5; j++) { if (a[i] > a[j]) { x = a[i]; a[i] = a[j]; a[j] = x; } } } for (k = 0; k < 4; k++) { printf("%d ", a[k]); } printf("%d\n", a[4]); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 2, 3, 4, 0, 69, 28, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 69, 0, 70], ["+", 0, 1, 0, 2, 3, 4, 0, 69, 71, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 69, 0, 73]]
0
169
7
#include <stdio.h> int main(void) { int p[5]; int n = 5; int i, j, temp; for (i = 0; i < 5; i++) { scanf("%d", &p[i]); } for (i = 0; i < n - 1; i++) { for (j = n - 1; j > i; j--) { if (p[j - 1] > p[j]) { temp = p[j]; p[j] = p[j - 1]; p[j - 1] = temp; } } } for (i = 0; i < 5; i++) { printf("%d", p[i]); if (i < 4) { printf(" "); } else { printf("\n"); } } return 0; }
#include <stdio.h> int main(void) { int p[5]; int n = 5; int i, j, temp; for (i = 0; i < 5; i++) { scanf("%d", &p[i]); } for (i = 0; i < n - 1; i++) { for (j = n - 1; j > i; j--) { if (p[j - 1] < p[j]) { temp = p[j]; p[j] = p[j - 1]; p[j - 1] = temp; } } } for (i = 0; i < 5; i++) { printf("%d", p[i]); if (i < 4) { printf(" "); } else { printf("\n"); } } return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 18]]
0
188
2
#include <stdio.h> #include <stdlib.h> int comp(const void *a, const void *b) { return *(int *)a - *(int *)b; } int main(void) { int i, n[5]; for (i = 0; i < 5; i++) { scanf("%d", &n[i]); getchar; } qsort(n, 5, sizeof(int), comp); for (i = 0; i < 4; i++) { printf("%d ", n[i]); } printf("%d\n", n[4]); return 0; }
#include <stdio.h> #include <stdlib.h> int comp(const void *a, const void *b) { return *(int *)b - *(int *)a; } int main(void) { int i, n[5]; for (i = 0; i < 5; i++) { scanf("%d", &n[i]); getchar; } qsort(n, 5, sizeof(int), comp); for (i = 0; i < 4; i++) { printf("%d ", n[i]); } printf("%d\n", n[4]); return 0; }
[["-", 0, 37, 0, 16, 31, 66, 28, 74, 51, 22], ["+", 0, 37, 0, 16, 31, 66, 28, 74, 51, 22], ["-", 0, 37, 0, 16, 12, 66, 28, 74, 51, 22], ["+", 0, 37, 0, 16, 12, 66, 28, 74, 51, 22]]
0
136
4
#include <stdio.h> int main() { int a, b, c, d, e; scanf("%d %d %d %d %d", &a, &b, &c, &d, &e); int num[5]; num[0] = a; num[1] = b; num[2] = c; num[3] = d; num[4] = e; int tmp = 0; int i = 0, j = 0; for (i = 0; i <= 3; i++) for (j = i; j <= 3; j++) if (num[j] >= num[j + 1]) { tmp = num[j]; num[j] = num[j + 1]; num[j + 1] = tmp; } printf("%d %d %d %d %d\n", num[4], num[3], num[2], num[1], num[0]); return 0; }
#include <stdio.h> int main() { int a, b, c, d, e; scanf("%d %d %d %d %d", &a, &b, &c, &d, &e); int num[5]; num[0] = a; num[1] = b; num[2] = c; num[3] = d; num[4] = e; int tmp = 0; int i = 0, j = 0; for (i = 0; i <= 3; i++) for (j = 0; j <= 3; j++) if (num[j] >= num[j + 1]) { tmp = num[j]; num[j] = num[j + 1]; num[j + 1] = tmp; } printf("%d %d %d %d %d\n", num[4], num[3], num[2], num[1], num[0]); return 0; }
[["-", 8, 9, 0, 7, 8, 7, 10, 11, 12, 22], ["+", 8, 9, 0, 7, 8, 7, 10, 11, 12, 13]]
0
202
2
#include <stdio.h> int main(void) { int num[5]; int i; int j; for (i = 0; i < 5; i++) { scanf("%d", &num[i]); } for (i = 0; i < 5; i++) { for (j = i + 1; j < 5; j++) { if (num[i] < num[j]) { int buf = num[i]; num[i] = num[j]; num[j] = buf; } } } for (i = 0; i < 5; i++) { printf("%d%c", num[i], i == 3 ? '\n' : ' '); } return (0); }
#include <stdio.h> int main(void) { int num[5]; int i; int j; for (i = 0; i < 5; i++) { scanf("%d", &num[i]); } for (i = 0; i < 5; i++) { for (j = i + 1; j < 5; j++) { if (num[i] < num[j]) { int buf = num[i]; num[i] = num[j]; num[j] = buf; } } } for (i = 0; i < 5; i++) { printf("%d%c", num[i], i == 4 ? '\n' : ' '); } return (0); }
[["-", 0, 2, 3, 4, 0, 41, 15, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 41, 15, 16, 12, 13]]
0
164
2
#include <stdio.h> int main(void) { int a[5], i, j, b; for (i = 0; i < 5; i++) { scanf("%d", &a[i]); } for (j = 0; j < 100; j++) { for (i = 0; i < 5; i++) { if (a[i] < a[i + 1]) { b = a[i]; a[i] = a[i + 1]; a[i + 1] = b; } } } printf("%d %d %d %d %d\n", a[0], a[1], a[2], a[3], a[4]); return 0; }
#include <stdio.h> int main(void) { int a[5], i, j, b; for (i = 0; i < 5; i++) { scanf("%d", &a[i]); } for (j = 0; j < 100; j++) { for (i = 0; i < 4; i++) { if (a[i] < a[i + 1]) { b = a[i]; a[i] = a[i + 1]; a[i + 1] = b; } } } printf("%d %d %d %d %d\n", a[0], a[1], a[2], a[3], a[4]); return 0; }
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
0
159
2
#include <iostream> using namespace std; int main() { int num[5]; for (int i = 0; i < 5; i++) cin >> num[i]; for (int i = 0; i < 5; i++) for (int j = i + 1; j < 5; j++) if (num[i] > num[j]) { int tmp = num[i]; num[i] = num[j]; num[j] = tmp; } for (int i = 0; i < 5; i++) { cout << num[i]; if (i == 4) break; cout << ' '; } cout << '\n'; return 0; }
#include <iostream> using namespace std; int main() { int num[5]; for (int i = 0; i < 5; i++) cin >> num[i]; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { if (num[i] < num[j]) { int tmp = num[i]; num[i] = num[j]; num[j] = tmp; } } } for (int i = 0; i < 5; i++) { cout << num[i]; if (i == 4) break; cout << ' '; } cout << '\n'; return 0; }
[["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 7, 8, 9, 0, 45], ["-", 8, 7, 8, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["+", 0, 7, 8, 9, 0, 7, 8, 9, 0, 46]]
1
154
6
#include <algorithm> #include <cstdio> using namespace std; int main() { int a[5], i, j, min, min_n; for (i = 0; i < 5; i++) scanf("%d", &a[i]); for (i = 0; i < 5; i++) { min = a[i]; min_n = i; for (j = i + 1; j < 5; j++) { if (min < a[j]) { min = a[j]; min_n = j; } } swap(a[i], a[min]); printf(i < 4 ? "%d " : "%d\n", a[i]); } return 0; }
#include <algorithm> #include <cstdio> using namespace std; int main() { int a[5], i, j, min, min_n; for (i = 0; i < 5; i++) scanf("%d", &a[i]); for (i = 0; i < 5; i++) { min = a[i]; min_n = i; for (j = i + 1; j < 5; j++) { if (min < a[j]) { min = a[j]; min_n = j; } } swap(a[i], a[min_n]); printf(i < 4 ? "%d " : "%d\n", a[i]); } return 0; }
[["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22]]
1
156
2
#include <iostream> using namespace std; int main() { int a[5]; int temp; cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4]; for (int i = 0; i < 4; i++) { for (int j = 1; j < 5; j++) { if (a[i] < a[j]) { temp = a[i]; a[i] = a[j]; a[j] = temp; } } } cout << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << " " << a[4] << endl; return 0; }
#include <iostream> using namespace std; int main() { int a[5]; int temp; cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4]; for (int i = 0; i < 4; i++) { for (int j = i + 1; j < 5; j++) { if (a[i] < a[j]) { temp = a[i]; a[i] = a[j]; a[j] = temp; } } } cout << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << " " << a[4] << endl; return 0; }
[["+", 0, 7, 10, 43, 49, 50, 51, 16, 31, 22], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72]]
1
166
2
#include <cstdio> #include <iostream> int a[5]; int swa; int change(int n) { swa = a[n], a[n] = a[n - 1], a[n - 1] = swa; } int main() { for (int i = 0; i < 5; i++) scanf("%d", &a[i]); for (int i = 4; i >= 0; i--) { for (int j = 4; j > 0; j--) { if (a[j - 1] > a[j]) change(j); } } for (int i = 0; i < 4; i++) printf("%d ", a[i]); printf("%d\n", a[4]); return 0; }
#include <cstdio> #include <iostream> int a[5]; int swa; int change(int n) { swa = a[n], a[n] = a[n - 1], a[n - 1] = swa; } int main() { for (int i = 0; i < 5; i++) scanf("%d", &a[i]); for (int i = 4; i >= 0; i--) { for (int j = 4; j > 0; j--) { if (a[j - 1] < a[j]) change(j); } } for (int i = 0; i < 4; i++) printf("%d ", a[i]); printf("%d\n", a[4]); return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
175
2
#include <algorithm> #include <iostream> using namespace std; int main() { int data[5]; for (int i = 0; i < 5; i++) cin >> data[i]; sort(data, data + 4, greater<int>()); for (int i = 0; i < 5; i++) cout << data[i] << " "; cout << data[4] << endl; }
#include <algorithm> #include <iostream> using namespace std; int main() { int data[5]; for (int i = 0; i < 5; i++) cin >> data[i]; sort(data, data + 5, greater<int>()); for (int i = 0; i < 4; i++) cout << data[i] << " "; cout << data[4] << endl; }
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
91
4
#include <iostream> using namespace std; int main(void) { int num[6], sta; for (int i = 0; i < 5; i++) { cin >> num[i]; } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (num[j] > num[j + 1]) { sta = num[j]; num[j] = num[j + 1]; num[j + 1] = sta; } } } for (int i = 0; i < 5; i++) { cout << num[i]; if (i == 4) cout << "\n"; else cout << " "; } }
#include <iostream> using namespace std; int main(void) { int num[6], sta; for (int i = 0; i < 5; i++) { cin >> num[i]; } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (num[j] < num[j + 1]) { sta = num[j]; num[j] = num[j + 1]; num[j + 1] = sta; } } } for (int i = 0; i < 5; i++) { cout << num[i]; if (i == 4) cout << "\n"; else cout << " "; } }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
162
2
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { int a[5]; for (int i = 0; i < 5; i++) cin >> a[i]; sort(a, a + 5); for (int i = 4; i >= 0; i--) (i == 4) ? cout << a[i] << endl : cout << a[i] << " "; return 0; }
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { int a[5]; for (int i = 0; i < 5; i++) cin >> a[i]; sort(a, a + 5); for (int i = 4; i >= 0; i--) (i == 0) ? cout << a[i] << endl : cout << a[i] << " "; return 0; }
[["-", 8, 1, 0, 41, 15, 23, 0, 16, 12, 13], ["+", 8, 1, 0, 41, 15, 23, 0, 16, 12, 13]]
1
95
2
#include <iostream> using namespace std; int main() { int A[5] = {}; cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4]; for (int i = 1; i < 5; ++i) { for (int j = i; j >= 1; --j) { if (A[j] < A[j - 1]) swap(A[j], A[j - 1]); else break; } } cout << A[0] << " " << A[1] << " " << A[2] << " " << A[3] << " " << A[4] << "\n"; return 0; }
#include <iostream> using namespace std; int main() { int A[5] = {}; cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4]; for (int i = 1; i < 5; ++i) { for (int j = i; j >= 1; --j) { if (A[j] > A[j - 1]) swap(A[j], A[j - 1]); else break; } } cout << A[0] << " " << A[1] << " " << A[2] << " " << A[3] << " " << A[4] << "\n"; return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
162
2