Dataset Viewer
Auto-converted to Parquet Duplicate
submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
1 value
status
stringclasses
1 value
code_size
int64
25
8.99k
cpu_time
float64
0
100
memory
float64
2.57k
110k
code
stringlengths
25
8.99k
input
stringlengths
2
4.87k
output
stringclasses
807 values
problem_description
stringlengths
358
9.83k
s246814716
p00001
Python
Accepted
139
20
5,596
m1=m2=m3=0 for i in range(10): m3=max(m3,int(input())) if m3>m2:m2,m3=m3,m2 if m2>m1:m1,m2=m2,m1 print(m1) print(m2) print(m3)
1819 2003 876 2840 1723 1673 3776 2848 1592 922
3776 2848 2840
<H1>List of Top 3 Hills</H1> <p> There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. </p> <p> Write a program which prints heights of the top three mountains in descending order. </p> <H2>Input</H2> <pre> Height of mountain 1 Height of mountain 2 Height of mountain 3...
s050837870
p00001
Python
Accepted
90
20
5,592
s = [int(input()) for i in range(10)] s.sort(reverse = True) for i in s[:3]: print(i)
1819 2003 876 2840 1723 1673 3776 2848 1592 922
3776 2848 2840
<H1>List of Top 3 Hills</H1> <p> There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. </p> <p> Write a program which prints heights of the top three mountains in descending order. </p> <H2>Input</H2> <pre> Height of mountain 1 Height of mountain 2 Height of mountain 3...
s003454110
p00002
Python
Accepted
84
20
5,588
while True: try:print(len(str(sum(map(int,input().split()))))) except:break
5 7 1 99 1000 999
2 3 4
<H1>Digit Number</H1> <p> Write a program which computes the digit number of sum of two integers <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> There are several test cases. Each test case consists of two non-negative integers <var>a</var> and <i>b</i> which are separeted by a space in a line. The input ter...
s611080249
p00002
Python
Accepted
97
10
4,620
try: while True: print len(str(sum(map(int, raw_input().split())))) except: pass
5 7 1 99 1000 999
2 3 4
<H1>Digit Number</H1> <p> Write a program which computes the digit number of sum of two integers <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> There are several test cases. Each test case consists of two non-negative integers <var>a</var> and <i>b</i> which are separeted by a space in a line. The input ter...
s257278998
p00003
Python
Accepted
166
40
5,592
for i in range(int(input())): a,b,c=map(lambda x:int(x)**2,input().split()) if a+b==c or b+c==a or c+a==b: print("YES") else: print("NO")
3 4 3 5 4 3 6 8 8 8
YES NO NO
<H1>Is it a Right Triangle?</H1> <p> Write a program which judges wheather given length of three side form a right triangle. Print "<span>YES</span>" if the given sides (integers) form a right triangle, "<span>NO</span>" if not so. </p> <H2>Input</H2> <p> Input consists of several data sets. In the first line, the ...
s004493480
p00003
Python
Accepted
199
10
4,644
n = int(raw_input()) for i in range(n): num = map(int, raw_input().split()) num.sort(reverse=True) if num[0]**2 == num[1]**2 + num[2]**2: print "YES" else: print "NO"
3 4 3 5 4 3 6 8 8 8
YES NO NO
<H1>Is it a Right Triangle?</H1> <p> Write a program which judges wheather given length of three side form a right triangle. Print "<span>YES</span>" if the given sides (integers) form a right triangle, "<span>NO</span>" if not so. </p> <H2>Input</H2> <p> Input consists of several data sets. In the first line, the ...
s131967940
p00004
Python
Accepted
176
20
5,616
while True: try: a,b,c,d,e,f=map(int,input().split()) print("{0:.3f} {1:.3f}".format((c*e-b*f)/(a*e-b*d)+1e-10,(a*f-c*d)/(a*e-b*d)+1e-10)) except:break
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 ...
s965021203
p00004
Python
Accepted
186
10
4,652
while True: try: a, b, c, d, e, f = map(float, raw_input().split()) except: break y = (c*d-a*f)/(b*d-a*e) x=(c - b*y) / a print "%.3f %.3f" % (x, y)
1 2 3 4 5 6 2 -1 -2 -1 -1 -5
-1.000 2.000 1.000 4.000
<H1>Simultaneous Equation</H1> <p> Write a program which solve a simultaneous equation:<br> <br> <var> ax + by = c</var><br> <var> dx + ey = f</var><br> <br> The program should print <var>x</var> and <var>y</var> for given <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var> and <var>f</var> (-1,000 ...
s487130866
p00005
Python
Accepted
138
20
5,652
import math while True: try: a,b=map(int,input().split()) print(*[math.gcd(a,b),a*b//math.gcd(a,b)]) except:break
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a li...
s594523890
p00005
Python
Accepted
201
10
4,632
def gcd(a,b): while b != 0: a, b = b, a % b return a while True: try: a, b = map(int, raw_input().split()) print gcd(a, b), a*b/ gcd(a,b) except: break
8 6 50000000 30000000
2 24 10000000 150000000
<H1>GCD and LCM</H1> <p> Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given <var>a</var> and <var>b</var>. </p> <H2>Input</H2> <p> Input consists of several data sets. Each data set contains <var>a</var> and <var>b</var> separated by a single space in a li...
s138251117
p00006
Python
Accepted
37
20
5,544
s = input().rstrip() print(s[::-1])
w32nimda
admin23w
<H1>Reverse Sequence</H1> <p> Write a program which reverses a given string <var>str</var>. </p> <H2>Input</H2> <p> <var>str</var> (the size of <var>str</var> &le; 20) is given in a line. </p> <H2>Output</H2> <p> Print the reversed <var>str</var> in a line. </p> <H2>Sample Input</H2> <pre> w32nimda </pre> <H2>O...
s553583886
p00006
Python
Accepted
34
20
5,548
a = input() b = a[::-1] print(b)
w32nimda
admin23w
<H1>Reverse Sequence</H1> <p> Write a program which reverses a given string <var>str</var>. </p> <H2>Input</H2> <p> <var>str</var> (the size of <var>str</var> &le; 20) is given in a line. </p> <H2>Output</H2> <p> Print the reversed <var>str</var> in a line. </p> <H2>Sample Input</H2> <pre> w32nimda </pre> <H2>O...
s467772394
p00007
Python
Accepted
92
20
5,664
import math x=100 for i in range(int(input())): x=math.ceil(x*1.05) print(str(x)+"000")
5
130000
<H1>Debt Hell</H1> <p> Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. </p> <p> Write a program which computes the amount of the debt in <var>n</var> wee...
s498456168
p00007
Python
Accepted
138
10
4,708
import math price = 100000.0 n = int(raw_input()) for i in range(n): price = math.ceil((price * 1.05) / 1000) * 1000 print int(price)
5
130000
<H1>Debt Hell</H1> <p> Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. </p> <p> Write a program which computes the amount of the debt in <var>n</var> wee...
s900517607
p00008
Python
Accepted
278
50
5,592
while True: try: n=int(input()) ans=0 for a in range(0,10): for b in range(0,10): for c in range(0,10): if 0<=(n-(a+b+c))<=9: ans+=1 print(ans) except: break
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = ...
s972309686
p00008
Python
Accepted
187
10
4,208
import sys x = [0]*51 for a in xrange(0,10): for b in xrange(0,10): for c in xrange(0,10): for d in xrange(0,10): x[a+b+c+d]+=1 for i in sys.stdin: print x[int(i)]
35 1
4 4
<H1>Sum of 4 Integers</H1> <p> Write a program which reads an integer <var>n</var> and identifies the number of combinations of <var>a, b, c</var> and <var>d</var> (0 &le; <var>a, b, c, d</var> &le; 9) which meet the following equality:<br> <br> <var>a + b + c + d = n</var><br> <br> For example, for <var>n</var> = ...
s862542423
p00009
Python
Accepted
757
80
14,372
# Aizu Problem 0009: Prime Number # import sys, math, os, bisect # read input: PYDEV = os.environ.get('PYDEV') if PYDEV=="True": sys.stdin = open("sample-input.txt", "rt") def primes2(n): """ Input n>=6, Returns a list of primes, 2 <= p < n """ n, correction = n-n%6+6, 2-(n%6>1) sieve = [True] * (n//...
10 3 11
4 2 5
<H1>Prime Number</H1> <p> Write a program which reads an integer <var>n</var> and prints the number of prime numbers which are less than or equal to <var>n</var>. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, ...
s707025188
p00010
Python
Accepted
1,196
20
5,696
import math class P(object): def __init__(self, x, y): self.x = x self.y = y def width(self, p): return math.sqrt((self.x - p.x)**2 + (self.y - p.y)**2) def __repr__(self): return '{0:.3f} {1:.3f}'.format(self.x, self.y) def calc_cos(a,b,c): return (b**2 + c**2 - a**2...
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>Circumscribed Circle of A Triangle.</H1> <p...
s888023198
p00010
Python
Accepted
1,688
30
6,984
# -*- coding: utf-8 -*- import cmath class Point(object): def __init__(self, x, y): self.point = complex(x, y) def __str__(self): return "x = {0}, y = {1}".format(self.point.real, self.point.imag) class Triangle(Point): def __init__(self, a, b, c): self.a = a self.b = b ...
1 0.0 0.0 2.0 0.0 2.0 2.0
1.000 1.000 1.414
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>Circumscribed Circle of A Triangle.</H1> <p...
s665570502
p00011
Python
Accepted
280
20
5,604
def run(): w = [i + 1 for i in range(int(input()))] n = int(input()) for _ in range(n): s1, s2 = list(map(int, input().split(','))) w[s1-1], w[s2-1] = w[s2-1], w[s1-1] print('\n'.join([str(_w) for _w in w])) if __name__ == '__main__': run()
5 4 2,4 3,5 1,2 3,4
4 1 2 5 3
<H1>Drawing Lots</H1> <p> Let's play Amidakuji. </p> <p> In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines. </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1"> </center> <br> <p>...
s003690790
p00011
Python
Accepted
203
10
4,208
import sys n = int(sys.stdin.readline()) sys.stdin.readline() l = range(1, n+1) for line in sys.stdin: a,b = map(int, line.strip().split(',')) l[a-1], l[b-1] = l[b-1], l[a-1] for x in l: print x
5 4 2,4 3,5 1,2 3,4
4 1 2 5 3
<H1>Drawing Lots</H1> <p> Let's play Amidakuji. </p> <p> In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines. </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_amida1"> </center> <br> <p>...
s316939428
p00012
Python
Accepted
1,214
20
5,592
import sys class P(object): def __init__(self, x, y): self.x = x self.y = y def __repr__(self): return 'P:{0:.3f} {1:.3f}'.format(self.x, self.y) class Line(object): def __init__(self, p1, p2): self.p1 = p1 self.p2 = p2 self.epsilon = 1e-8 def is_over(...
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a ...
s780464984
p00012
Python
Accepted
1,354
30
7,000
# -*- coding: utf-8 -*- import sys import cmath import math class Point(object): def __init__(self, x, y): self.point = complex(x, y) def __str__(self): return "x = {0}, y = {1}".format(self.point.real, self.point.imag) class Triangle(Point): def __init__(self, a, b, c): self.a =...
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5 0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>A Point in a Triangle</H1> <p> There is a ...
s703592948
p00013
Python
Accepted
212
20
5,600
import sys def run(): cars = [] for _n in sys.stdin: n = int(_n) if n == 0: print(cars.pop()) else: cars.append(n) if __name__ == '__main__': run()
1 6 0 8 10 0 0 0
6 10 8 1
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail trac...
s325857017
p00013
Python
Accepted
220
20
5,596
counter = -1 train = [] while True: try: x = int(input()) except: break if x == 0 and len(train) != 0: print(train[counter]) train.remove(train[counter]) counter -= 1 else: train.append(x) counter += 1
1 6 0 8 10 0 0 0
6 10 8 1
<H1>Switching Railroad Cars</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_switchingRailroadCars"> </center> <br> <p> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail trac...
s125911650
p00014
Python
Accepted
158
20
5,592
while True: try: d = int(input()) except EOFError: break sum = 0 for i in range(600 // d): j = i * d sum += j * j * d print(sum)
20 10
68440000 70210000
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>Integral</H1> <p> Write a program which com...
s451909678
p00014
Python
Accepted
155
10
4,200
def f(x): return x ** 2 while True: try: d = input() except: break; ans = 0 for i in range(600 / d): ans += f(i * d) * d print ans
20 10
68440000 70210000
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>Integral</H1> <p> Write a program which com...
s654823101
p00015
Python
Accepted
186
10
4,668
n = int(raw_input()) for i in range(n): a = long(raw_input()) b = long(raw_input()) tmp = str(a+b) if len(tmp) > 80: print "overflow" else: print tmp
6 1000 800 9999999999999999999999999999999999999999 1 99999999999999999999999999999999999999999999999999999999999999999999999999999999 1 99999999999999999999999999999999999999999999999999999999999999999999999999999999 0 100000000000000000000000000000000000000000000000000000000000000000000000000000000 1 1000000000000000...
1800 10000000000000000000000000000000000000000 overflow 99999999999999999999999999999999999999999999999999999999999999999999999999999999 overflow overflow
<H1>National Budget</H1> <p> A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647. </p> <p> Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of...
s532075002
p00015
Python
Accepted
1,212
20
5,604
# 国家予算 def main(): N = int(input()) for _ in range(N): n1 = input().strip() n2 = input().strip() #print(f"n1: {n1}\nn2: {n2}") if len(n1) > 80 or len(n2) > 80: print("overflow") continue print(add(n1, n2)) return def add(n1, n2): """n1,...
6 1000 800 9999999999999999999999999999999999999999 1 99999999999999999999999999999999999999999999999999999999999999999999999999999999 1 99999999999999999999999999999999999999999999999999999999999999999999999999999999 0 100000000000000000000000000000000000000000000000000000000000000000000000000000000 1 1000000000000000...
1800 10000000000000000000000000000000000000000 overflow 99999999999999999999999999999999999999999999999999999999999999999999999999999999 overflow overflow
<H1>National Budget</H1> <p> A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647. </p> <p> Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of...
s487301613
p00016
Python
Accepted
242
20
5,720
import math x, y = 0, 0 angle = math.pi / 2 while True: d, a = map(int, input().split(",")) if (d, a) == (0, 0): break x += math.cos(angle) * d y += math.sin(angle) * d angle -= a * math.pi / 180 print(int(x), int(y), sep="\n")
56,65 97,54 64,-4 55,76 42,-27 43,80 87,-86 55,-6 89,34 95,5 0,0
171 -302
<H1>Treasure Hunt</H1> <p> When a boy was cleaning up after his grand father passing, he found an old paper: </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_treasure_en"><br> </center> <br/> <!-- <center> <table> <tr> <td align="top"> <img src="https://judgeapi.u-aizu.ac.jp/resources/im...
s295482187
p00016
Python
Accepted
299
30
6,864
import math import cmath coordinates = 0 ang = 90 while True: line = list(map(float, input().split(","))) if line[0] == 0 and line[1] == 0: break coordinates += cmath.rect(line[0], math.radians(ang)) ang -= line[1] print(int(coordinates.real)) print(int(coordinates.imag))
56,65 97,54 64,-4 55,76 42,-27 43,80 87,-86 55,-6 89,34 95,5 0,0
171 -302
<H1>Treasure Hunt</H1> <p> When a boy was cleaning up after his grand father passing, he found an old paper: </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_treasure_en"><br> </center> <br/> <!-- <center> <table> <tr> <td align="top"> <img src="https://judgeapi.u-aizu.ac.jp/resources/im...
s361354970
p00017
Python
Accepted
254
10
4,764
try: while True: b = raw_input() import string t = string.maketrans("abcdefghijklmnopqrstuvwxyz","bcdefghijklmnopqrstuvwxyza") while not("this" in b or "the" in b or "that" in b): b = b.translate(t) print b except: pass
xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.
this is the picture that i took in the trip.
<H1>Caesar Cipher</H1> <p> In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would ...
s692201848
p00017
Python
Accepted
223
20
4,376
import sys,string a = string.ascii_lowercase t = string.maketrans(a,a[1:]+a[0]) for s in sys.stdin: s = s.strip() while not ('the' in s or 'this' in s or 'that' in s): s = s.translate(t) print s
xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.
this is the picture that i took in the trip.
<H1>Caesar Cipher</H1> <p> In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would ...
s200929588
p00018
Python
Accepted
320
20
5,600
s = input() s = s.split() n = [] for i in s: n.append(int(i)) isSorted = False while(not isSorted): isSorted = True for i in range(4): if n[i] < n[i + 1]: temp = n[i] n[i] = n[i + 1] n[i + 1] = temp isSorted = False print(n[0],n[1],n[2],n[3],n[4])
3 6 9 7 5
9 7 6 5 3
<H1>Sorting Five Numbers</H1> <p> Write a program which reads five numbers and sorts them in descending order. </p> <H2>Input</H2> <p> Input consists of five numbers <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var> and <var>e</var> (-100000 &le; <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>,<var>e</v...
s583977792
p00018
Python
Accepted
80
10
4,616
n = map(int, raw_input().split()) n.sort(reverse=True) for i in n: print i,
3 6 9 7 5
9 7 6 5 3
<H1>Sorting Five Numbers</H1> <p> Write a program which reads five numbers and sorts them in descending order. </p> <H2>Input</H2> <p> Input consists of five numbers <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var> and <var>e</var> (-100000 &le; <var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>,<var>e</v...
s167442920
p00019
Python
Accepted
77
20
5,576
n = int(input()) base = 1 for i in range(n): base *= i + 1 print(base)
5
120
<H1>Factorial</H1> <p> Write a program which reads an integer <var>n</var> and prints the factorial of <var>n</var>. You can assume that <var>n</var> &le; 20. </p> <H2>Input</H2> <p> An integer <var>n</var> (1 &le; <var>n</var> &le; 20) in a line. </p> <H2>Output</H2> <p> Print the factorial of <var>n</var> in a ...
s078584869
p00019
Python
Accepted
54
20
5,648
import math n = int(input()) print(math.factorial(n))
5
120
<H1>Factorial</H1> <p> Write a program which reads an integer <var>n</var> and prints the factorial of <var>n</var>. You can assume that <var>n</var> &le; 20. </p> <H2>Input</H2> <p> An integer <var>n</var> (1 &le; <var>n</var> &le; 20) in a line. </p> <H2>Output</H2> <p> Print the factorial of <var>n</var> in a ...
s565902397
p00020
Python
Accepted
39
20
5,532
n = input().rstrip() print(n.upper())
this is a pen.
THIS IS A PEN.
<H1>Capitalize</H1> <p> Write a program which replace all the lower-case letters of a given text with the corresponding captital letters. </p> <H2>Input</H2> <p> A text including lower-case letters, periods, and space is given in a line. The number of characters in the text is less than or equal to 200. </p> <H2>...
s009469424
p00020
Python
Accepted
29
10
4,604
print raw_input().swapcase()
this is a pen.
THIS IS A PEN.
<H1>Capitalize</H1> <p> Write a program which replace all the lower-case letters of a given text with the corresponding captital letters. </p> <H2>Input</H2> <p> A text including lower-case letters, periods, and space is given in a line. The number of characters in the text is less than or equal to 200. </p> <H2>...
s531181563
p00021
Python
Accepted
335
20
5,636
E = 10 ** -10 def check(lst): x1, y1, x2, y2, x3, y3, x4, y4 = lst vabx, vaby = x2 - x1, y2 - y1 vcdx, vcdy = x4 - x3, y4 - y3 if abs(vabx * vcdy - vcdx * vaby) < E: return True else: return False n = int(input()) for _ in range(n): plst = list(map(float, input().split())) print("YES" if check(pl...
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>Parallelism</H1> <p> There are four points:...
s663715146
p00021
Python
Accepted
348
20
5,632
n=int(input()) for nn in range(n): x1,y1,x2,y2,x3,y3,x4,y4=list(map(float,input().split())) if x2-x1==0 or x4-x3==0: if x1==x2 and x3==x4: print("YES") else: print("NO") else: if abs((y2-y1)/(x2-x1)-(y4-y3)/(x4-x3))<10**-10: print("YES") el...
2 0.0 0.0 1.0 1.0 1.0 0.0 2.0 1.0 3.0 2.0 9.0 6.0 13.0 5.0 7.0 9.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>Parallelism</H1> <p> There are four points:...
s546492824
p00022
Python
Accepted
326
40
5,636
while 1: n=int(input()) if n==0:break nlist=[] nans=-100001 for i in range(n): nlist.append(int(input())) nkeep=0 for i in nlist: if nkeep<0: nkeep=i else: nkeep+=i if nans<nkeep:nans=nkeep if max(nlist)<0:nans=max(nlist) print(...
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence...
s395291099
p00022
Python
Accepted
251
40
5,604
while True: N=int(input()) if N==0: break num=0 res=-11111111 for i in range(N): a=int(input()) num=max(num+a, a) #print(num) res=max(num, res) #print(res) print(res)
7 -5 -1 6 4 9 -6 -7 13 1 2 3 2 -2 -1 1 2 3 2 1 -2 1 3 1000 -200 201 0
19 14 1001
<H1>Maximum Sum Sequence</H1> <p> Given a sequence of numbers <var>a<sub>1</sub></var>, <var>a<sub>2</sub></var>, <var>a<sub>3</sub></var>, ..., <var>a<sub>n</sub></var>, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a <i>contiquous</i> subsequence...
s302002874
p00023
Python
Accepted
440
30
6,788
for i in range(int(input())): xa, ya, ra, xb, yb, rb = map(float, input().split(' ')) ab_length = ((xa - xb) ** 2 + (ya - yb) ** 2) ** 0.5 if ra > rb: max_r, min_r, min_c = ra, rb, 2 else: max_r, min_r, min_c = rb, ra, -2 if ab_length > ra + rb: ans = 0 elif ab_length <=...
2 0.0 0.0 5.0 0.0 0.0 4.0 0.0 0.0 2.0 4.1 0.0 2.0
2 0
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>Circles Intersection</H1> <p> You are given...
s257754719
p00023
Python
Accepted
364
20
4,308
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys input() for s in sys.stdin: d = map(float,s.split()) xa,ya,ra,xb,yb,rb = d[0],d[1],d[2],d[3],d[4],d[5] if ((xa-xb)**2+(ya-yb)**2)**0.5 > ra + rb: print 0 elif ((xa-xb)**2+(ya-yb)**2)**0.5 + rb < ra : print 2 elif ((xa-xb)**2+(ya-yb)**2)**0.5 ...
2 0.0 0.0 5.0 0.0 0.0 4.0 0.0 0.0 2.0 4.1 0.0 2.0
2 0
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>Circles Intersection</H1> <p> You are given...
s473210902
p00024
Python
Accepted
163
20
5,636
import math while True: try: v = float(input()) print(math.ceil(v ** 2 / 19.6 / 5) + 1) #print(v ** 2 / 19.6 // 5 + 2) except EOFError: break
25.4 25.4
8 8
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>Physical Experiments</H1> <p> Ignoring the ...
s106557815
p00024
Python
Accepted
170
20
5,588
while True: try: v=float(input()) t=v/9.8 y=4.9*t**2 N=0 while y>5*(N-1): N +=1 print(N) except:break
25.4 25.4
8 8
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>Physical Experiments</H1> <p> Ignoring the ...
s894905979
p00025
Python
Accepted
311
10
4,640
while True: try: a = map(int, raw_input().split()) b = map(int, raw_input().split()) hit = blow = 0 for i in range(4): if a[i] == b [i]: hit+=1 elif a[i] in b: blow+=1 print hit, blow except: break
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers includ...
s326950980
p00025
Python
Accepted
428
20
5,592
while True: try: a=list(map(int,input().split())) b=list(map(int,input().split())) hit,blow=0,0 ac=0 for i in a: bc=0 ac +=1 for j in b: bc +=1 if i==j: if ac==bc: ...
9 1 8 2 4 1 5 9 4 6 8 2 4 6 3 2
1 1 3 0
<H1>Hit and Blow</H1> <p> Let's play Hit and Blow game. <i>A</i> imagines four numbers and <i>B</i> guesses the numbers. After <i>B</i> picks out four numbers, <i>A</i> answers: </p> <ul> <li> The number of numbers which have the same place with numbers <i>A</i> imagined (Hit) </li> <li> The number of numbers includ...
s984761202
p00026
Python
Accepted
1,295
20
5,628
peper=[[0 for i in range(14)]for j in range(14)] while True: try: x,y,s=map(int,input().split(",")) x +=2 y +=2 if s==3: peper[y][x] +=1 peper[y][x-1] +=1 peper[y][x-2] +=1 peper[y][x+1] +=1 peper[y][x+2] +=1 pep...
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From th...
s083529398
p00026
Python
Accepted
919
30
6,776
#!/usr/bin/python paper = [[0] * 10 for i in range(10)] def small(x, y): p = [[x, y]] for i, j in zip([-1, 0, 1, 0], [0, -1, 0, 1]): p.append([x + i, y + j]) return p def middle(x, y): p = small(x, y) for i, j in zip([1, -1, 1, -1], [1, 1, -1, -1]): p.append([x + i, y + j]) re...
2,5,3 3,6,1 3,4,2 4,5,2 3,6,3 2,4,1
77 5
<H1>Dropping Ink</H1> <p> As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (<var>x</var>, <var>y</var>) coordinate system. </p> <p> We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From th...
s132080370
p00027
Python
Accepted
282
10
4,648
M=[ 31, 29, 31, 30, 31,30,31,31,30,31,30,31] DAY=["Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"] m=2 d=29 while True: m,d=map( int , raw_input().split() ) if m==d==0: quit() else: x=0 for i in range(m-1): x+=M[i] x+=d print DAY[x%7]
1 1 2 29 0 0
Thursday Sunday
<H1>What day is today?</H1> <p> Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. </p> <H2>Input</H2> <p> The input is a sequence of datasets. The end of the input is indicat...
s474160057
p00027
Python
Accepted
239
30
6,040
from datetime import date dic={3:"Thursday",4:"Friday",5:"Saturday",6:"Sunday",0:"Monday",1:"Tuesday",2:"Wednesday"} while True: m,d=map(int,input().split()) if m==0 and d==0: break print(dic[date(2004,m,d).weekday()])
1 1 2 29 0 0
Thursday Sunday
<H1>What day is today?</H1> <p> Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. </p> <H2>Input</H2> <p> The input is a sequence of datasets. The end of the input is indicat...
s561616795
p00028
Python
Accepted
214
20
5,596
lis=[0 for i in range(100)] while True: try: N=int(input()) lis[N-1] +=1 except: for j in range(100): if lis[j]==max(lis): print(j+1) break
5 6 3 5 8 7 5 3 9 7 3 4
3 5
<h1>Mode Value</h1> <p> Your task is to write a program which reads a sequence of integers and prints mode values of the sequence. The mode value is the element which occurs most frequently. </p> <H2>Input</H2> <p> A sequence of integers <var>a<sub>i</sub></var> (1 &le; <var>a<sub>i</sub></var> &le; 100). The numb...
s200129812
p00028
Python
Accepted
187
10
4,204
hist = [0 for i in range(100)] l = [] while True: try: hist[input() - 1] += 1 except: break; for k in filter(lambda x: max(hist) == x[1], enumerate(hist)): print k[0] + 1
5 6 3 5 8 7 5 3 9 7 3 4
3 5
<h1>Mode Value</h1> <p> Your task is to write a program which reads a sequence of integers and prints mode values of the sequence. The mode value is the element which occurs most frequently. </p> <H2>Input</H2> <p> A sequence of integers <var>a<sub>i</sub></var> (1 &le; <var>a<sub>i</sub></var> &le; 100). The numb...
s986918406
p00029
Python
Accepted
146
30
5,968
from collections import Counter s = input().split() po = Counter(s) s.sort(reverse=True,key=lambda x:len(x)) print(po.most_common()[0][0],s[0])
Thank you for your mail and your lectures
your lectures
<H1>English Sentence</H1> <p> Your task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently in the text. The second one is the word which has the maximum number of letters. </p> <p> The text includes only alphabetical characters and spaces. A word i...
s319878285
p00029
Python
Accepted
281
0
4,640
# coding: utf-8 # Your code here! a = raw_input().lower() a = " "+a+" " s = a.split() ss = "" tmp = "" n = 0 for i in s: if len(ss) < len(i): ss = i for i in s: i = " " + i + " " if a.count(i) > n: n = a.count(i) tmp = i.strip() print tmp, ss
Thank you for your mail and your lectures
your lectures
<H1>English Sentence</H1> <p> Your task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently in the text. The second one is the word which has the maximum number of letters. </p> <p> The text includes only alphabetical characters and spaces. A word i...
s178930722
p00030
Python
Accepted
251
20
5,632
from itertools import combinations while True: n,s = [int(i) for i in input().split()] if (n, s) == (0, 0): break ans = 0 for num in combinations(range(10),n): if sum(num) == s: ans += 1 print(ans)
3 6 3 1 0 0
3 0
<H1>整数の和</H1> <p> 0 から 9 の数字から異なる <var>n</var> 個の数を取り出して合計が <var>s</var> となる組み合わせの数を出力するプログラムを作成してください。<var>n</var> 個の数はおのおの 0 から 9 までとし、1つの組み合わせに同じ数字は使えません。たとえば、<var>n</var> が 3 で <var>s</var> が 6 のとき、3 個の数字の合計が 6 になる組み合わせは、<br/> <br/> 1 + 2 + 3 = 6<br/> 0 + 1 + 5 = 6<br/> 0 + 2 + 4 = 6<br/> <br/> の 3 通りとなります。 </p...
s117020169
p00030
Python
Accepted
223
10
4,736
import itertools l=range(10) while True: n,s=map(int, raw_input().split()) if n==0: break cnt=0 for i in list(itertools.combinations(l,n)): if s == sum(i): cnt+=1 print cnt
3 6 3 1 0 0
3 0
<H1>整数の和</H1> <p> 0 から 9 の数字から異なる <var>n</var> 個の数を取り出して合計が <var>s</var> となる組み合わせの数を出力するプログラムを作成してください。<var>n</var> 個の数はおのおの 0 から 9 までとし、1つの組み合わせに同じ数字は使えません。たとえば、<var>n</var> が 3 で <var>s</var> が 6 のとき、3 個の数字の合計が 6 になる組み合わせは、<br/> <br/> 1 + 2 + 3 = 6<br/> 0 + 1 + 5 = 6<br/> 0 + 2 + 4 = 6<br/> <br/> の 3 通りとなります。 </p...
s742332617
p00031
Python
Accepted
188
20
5,612
import sys for line in sys.stdin: l = bin(int(line)).lstrip("0b")[::-1] ans = [] for i,bit in enumerate(l): if bit == "1": ans.append(2**i) print(*ans)
5 7 127
1 4 1 2 4 1 2 4 8 16 32 64
<H1>Weight</H1> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_weight"></center> <br/> <p> 祖母が天秤を使っています。天秤は、二つの皿の両方に同じ目方のものを載せると釣合い、そうでない場合には、重い方に傾きます。10 個の分銅の重さは、軽い順に 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g です。 </p> <p> 祖母は、「1kg くらいまでグラム単位で量れるのよ。」と言います。「じゃあ、試しに、ここにあるジュースの重さを量ってよ」...
s171580963
p00031
Python
Accepted
314
10
4,336
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import itertools for s in sys.stdin: lis_weight = [1,2,4,8,16,32,64,128,256,512] lis = [] d = int(s) lis_weight.reverse() for e in lis_weight: if d >= e: lis.append(e) d -= e lis.reverse() for e in lis: print e, print
5 7 127
1 4 1 2 4 1 2 4 8 16 32 64
<H1>Weight</H1> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_weight"></center> <br/> <p> 祖母が天秤を使っています。天秤は、二つの皿の両方に同じ目方のものを載せると釣合い、そうでない場合には、重い方に傾きます。10 個の分銅の重さは、軽い順に 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g です。 </p> <p> 祖母は、「1kg くらいまでグラム単位で量れるのよ。」と言います。「じゃあ、試しに、ここにあるジュースの重さを量ってよ」...
s121948129
p00032
Python
Accepted
200
20
5,604
import sys rect = 0 dia = 0 for line in sys.stdin: a,b,c = [int(i) for i in line.split(",")] if a**2 + b**2 == c**2: rect += 1 if a == b: dia += 1 print(rect) print(dia)
3,4,5 5,5,8 4,4,4 5,4,3
1 2
<H1>プラスティック板</H1> <p> 機械に辺・対角線の長さのデータを入力し、プラスティック板の型抜きをしている工場があります。この工場では、サイズは様々ですが、平行四辺形の型のみを切り出しています。あなたは、切り出される平行四辺形のうち、長方形とひし形の製造個数を数えるように上司から命じられました。 </p> <p> 「機械に入力するデータ」を読み込んで、長方形とひし形の製造個数を出力するプログラムを作成してください。 </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_plastic"></center> <b...
s623724001
p00032
Python
Accepted
233
20
5,592
hisi=0 tyou=0 while True: try: a,b,c=map(int,input().split(",")) if a**2+b**2==c**2: tyou +=1 elif a==b: hisi +=1 except: print(tyou) print(hisi) break
3,4,5 5,5,8 4,4,4 5,4,3
1 2
<H1>プラスティック板</H1> <p> 機械に辺・対角線の長さのデータを入力し、プラスティック板の型抜きをしている工場があります。この工場では、サイズは様々ですが、平行四辺形の型のみを切り出しています。あなたは、切り出される平行四辺形のうち、長方形とひし形の製造個数を数えるように上司から命じられました。 </p> <p> 「機械に入力するデータ」を読み込んで、長方形とひし形の製造個数を出力するプログラムを作成してください。 </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_plastic"></center> <b...
s707778222
p00033
Python
Accepted
348
20
5,600
n = int(input()) for i in range(n): data = [int(i) for i in input().split()] flag = False a = [0] b = [0] for ball in data: if ball > a[-1]: a.append(ball) elif ball > b[-1]: b.append(ball) else: flag = True break print("NO"...
2 3 1 4 2 5 6 7 8 9 10 10 9 8 7 6 5 4 3 2 1
YES NO
<H1>玉</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ball"> </center> <br/> <p> 図のように二股に分かれている容器があります。1 から 10 までの番号が付けられた10 個の玉を容器の開口部 A から落とし、左の筒 B か右の筒 C に玉を入れます。板 D は支点 E を中心に左右に回転できるので、板 D を動かすことで筒 B と筒 C のどちらに入れるか決めることができます。 </p> <p> 開口部 A から落とす玉の並びを与えます。それらを順番に筒 B 又は筒 Cに入れていきま...
s082288167
p00033
Python
Accepted
277
20
5,588
from sys import stdin for _ in range(int(stdin.readline())): s = list(map(int, stdin.readline().split())) a = 0 b = 0 for c in s: if a<c: a=c elif b<c: b=c else: print("NO") break else: print("YES")
2 3 1 4 2 5 6 7 8 9 10 10 9 8 7 6 5 4 3 2 1
YES NO
<H1>玉</H1> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_ball"> </center> <br/> <p> 図のように二股に分かれている容器があります。1 から 10 までの番号が付けられた10 個の玉を容器の開口部 A から落とし、左の筒 B か右の筒 C に玉を入れます。板 D は支点 E を中心に左右に回転できるので、板 D を動かすことで筒 B と筒 C のどちらに入れるか決めることができます。 </p> <p> 開口部 A から落とす玉の並びを与えます。それらを順番に筒 B 又は筒 Cに入れていきま...
s820880043
p00034
Python
Accepted
353
20
5,608
import sys for line in sys.stdin: po = [int(i) for i in line.split(",")] l = [0] for i in range(10): l.append(l[-1] + po[i]) v1,v2 = po[10:] t = l[-1] / (v1+v2) for i in range(10): if l[i] < v1*t < l[i+1]: print(i+1) break elif l[i] == v1*t: ...
1,1,1,1,1,1,1,1,1,1,40,60 1,1,1,1,1,3,3,3,3,3,50,50 10,10,10,10,10,10,10,10,10,10,50,49
4 7 6
<H1>鉄道路線</H1> <p> 複線(上りと下りが別の線路になっていてどこででもすれ違える)の鉄道路線があります。この路線には終端駅を含めて11 の駅があり、それぞれの駅と駅の間は図で示す区間番号で呼ばれています。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_railway"> </center> <br/> <p> この路線の両方の終端駅から列車が同時に出発して、途中で停まらずに走ります。各区間の長さと2 本の列車の速度を読み込んで、それぞれの場合について列車がすれ違う区間の番号を出力するプログラムを作...
s605510422
p00034
Python
Accepted
277
20
5,644
from sys import stdin import bisect while(True): try: *ls,v1,v2 = list(map(int,stdin.readline().split(","))) rs = [sum(ls[:i+1]) for i in range(len(ls))] idx = bisect.bisect_left(rs,rs[-1]*v1/(v1+v2)) print(idx+1) except: break
1,1,1,1,1,1,1,1,1,1,40,60 1,1,1,1,1,3,3,3,3,3,50,50 10,10,10,10,10,10,10,10,10,10,50,49
4 7 6
<H1>鉄道路線</H1> <p> 複線(上りと下りが別の線路になっていてどこででもすれ違える)の鉄道路線があります。この路線には終端駅を含めて11 の駅があり、それぞれの駅と駅の間は図で示す区間番号で呼ばれています。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_railway"> </center> <br/> <p> この路線の両方の終端駅から列車が同時に出発して、途中で停まらずに走ります。各区間の長さと2 本の列車の速度を読み込んで、それぞれの場合について列車がすれ違う区間の番号を出力するプログラムを作...
s608188348
p00035
Python
Accepted
629
20
5,652
import sys import math for line in sys.stdin: xa,ya,xb,yb,xc,yc,xd,yd = [float(i) for i in line.split(",")] # 図形の凸性:各頂点における外積を計算し、一つでも符号の異なるものがあれば非凸 ab = (xb-xa,yb-ya) bc = (xc-xb,yc-yb) cd = (xd-xc,yd-yc) da = (xa-xd,ya-yd) va = da[0]*ab[1] - da[1]*ab[0] vb = ab[0]*bc[1] - ab[1]*bc...
0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0 0.0,0.0,3.0,0.0,1.0,1.0,1.0,3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>凸?</H1> <p> 平面上の異なる 4 点 $A (x_a, y_a)$, $...
s145056111
p00035
Python
Accepted
568
20
5,588
from sys import stdin while(True): try: xa,ya,xb,yb,xc,yc,xd,yd = map(float, stdin.readline().split(",")) ab = [xb-xa,yb-ya] bc = [xc-xb,yc-yb] cd = [xd-xc,yd-yc] da = [xa-xd,ya-yd] cr1 = ab[0]*bc[1] - ab[1]*bc[0] cr2 = bc[0]*cd[1] - bc[1]*cd[0] cr3 =...
0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0 0.0,0.0,3.0,0.0,1.0,1.0,1.0,3.0
YES NO
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>凸?</H1> <p> 平面上の異なる 4 点 $A (x_a, y_a)$, $...
s148285422
p00036
Python
Accepted
234
20
5,568
ans = [0,0,0,"C",0,0,0,0,"G","A","E",0,0,0,0,"D",0,"F",0,0,0,0,0,0,"B"] while(True): h = "" for _ in range(8): h +=input() print(ans[h.rfind("1")-h.find("1")]) try: b =input() except: break
00000000 00000000 01100000 00110000 00000000 00000000 00000000 00000000 00011110 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00110000 00110000 00000000 00000000 00000000 00000000
E C A
<H1>平面上の図形</H1> <p> 縦 8、横 8 のマスからなる図 1 のような平面があります。 <br> <center> <table cellspacing=0 cellpadding=0> <tr><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td></tr> <tr><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td></tr> <tr><td>□</td><td>□</td><td>□</td>...
s036040581
p00036
Python
Accepted
749
20
5,584
def trim(N): num=[] for x in range(8): for y in range(8): if N[y][x]=="1": if not num: refer=(x,y) num.append((x,y)) num=[(x-refer[0],y-refer[1]) for x,y in num] return num def points(point): if point==[(0,0),(0,1),(1,0),(1,1)]:...
00000000 00000000 01100000 00110000 00000000 00000000 00000000 00000000 00011110 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00110000 00110000 00000000 00000000 00000000 00000000
E C A
<H1>平面上の図形</H1> <p> 縦 8、横 8 のマスからなる図 1 のような平面があります。 <br> <center> <table cellspacing=0 cellpadding=0> <tr><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td></tr> <tr><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td><td>□</td></tr> <tr><td>□</td><td>□</td><td>□</td>...
s613978942
p00037
Python
Accepted
796
20
5,572
k = [[1,2,4,8],[4,8,1,2],[8,1,2,4],[2,4,8,1]] m = [[0]*5 for _ in range(5)] for i in range(9): a = input() if i%2: for j in range(5): if a[j] == '1': m[i//2][j] |= 4 m[i//2+1][j] |= 1 else: for j in range(4): if a[j] == '1': ...
1111 00001 0110 01011 0010 01111 0010 01001 0111
RRRRDDDDLLLUUURRDDLURULLDDDRRRUUUULLLL
<H1>格子上の経路</H1> <p> 上から見ると図 1 のような形の格子状の広場があります。この格子の各辺に「壁」があるかないかを 0 と 1 の並びで表します。点 A に立って壁に右手をつき、壁に右手をついたまま、矢印の方向に歩き続けて再び点 A に戻ってくるまでの経路を出力するプログラムを作成してください。 </p> <center> <table> <tr><th> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_pathOnGrid1"> </t></tr> </table> <table> <tr><th> 図1 </th></tr...
s275711711
p00037
Python
Accepted
612
10
4,276
#!/usr/bin/env python # -*- coding: utf-8 -*- def iswall(x,y,di): if di == 0: return x<4 and d[2*y][x] == "1" if di == 1: return y<4 and d[2*y+1][x] == "1" if di == 2: return x>0 and d[2*y][x-1] == "1" if di == 3: return y>0 and d[2*y-1][x] == "1" def nextdi(x,y,di): di = (di-1) %4 while True: if iswal...
1111 00001 0110 01011 0010 01111 0010 01001 0111
RRRRDDDDLLLUUURRDDLURULLDDDRRRUUUULLLL
<H1>格子上の経路</H1> <p> 上から見ると図 1 のような形の格子状の広場があります。この格子の各辺に「壁」があるかないかを 0 と 1 の並びで表します。点 A に立って壁に右手をつき、壁に右手をついたまま、矢印の方向に歩き続けて再び点 A に戻ってくるまでの経路を出力するプログラムを作成してください。 </p> <center> <table> <tr><th> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_pathOnGrid1"> </t></tr> </table> <table> <tr><th> 図1 </th></tr...
s685224454
p00038
Python
Accepted
582
30
6,000
from collections import Counter ans = ["null","one pair","two pair","three card","straight","full house","four card"] straits = [[i,i+1,i+2,i+3,i+4]for i in range(1,10)] straits.append([1,10,11,12,13]) while(True): try: l = sorted(list(map(int,input().split(",")))) v = sorted(list(Counter(l).value...
1,2,3,4,1 2,3,2,3,12 12,13,11,12,12 7,6,7,6,7 3,3,2,3,3 6,7,8,9,10 11,12,10,1,13 11,12,13,1,2
one pair two pair three card full house four card straight straight null
<H1>ポーカー</H1> <p> ポーカーの手札データを読み込んで、それぞれについてその役を出力するプログラムを作成してください。ただし、この問題では、以下のルールに従います。 </p> <ul> <li>ポーカーはトランプ 5 枚で行う競技です。</li> <li>同じ数字のカードは 5 枚以上ありません。</li> <li>ジョーカーは無いものとします。</li> <li>以下のポーカーの役だけを考えるものとします。(番号が大きいほど役が高くなります。)</li> </ul> <ol style="margin-left:40px"> <li>役なし(以下に挙げるどれにも当てはまらない)</li> <li>ワンペア...
s524587750
p00038
Python
Accepted
999
10
4,284
hand = None def find(trg, start = 0): count = 0 m = -1 mm = 0 for i in range(start, 5): if m == hand[i]: count += 1 else: if count == trg: mm = i break m = hand[i] count = 1 if count == trg: mm ...
1,2,3,4,1 2,3,2,3,12 12,13,11,12,12 7,6,7,6,7 3,3,2,3,3 6,7,8,9,10 11,12,10,1,13 11,12,13,1,2
one pair two pair three card full house four card straight straight null
<H1>ポーカー</H1> <p> ポーカーの手札データを読み込んで、それぞれについてその役を出力するプログラムを作成してください。ただし、この問題では、以下のルールに従います。 </p> <ul> <li>ポーカーはトランプ 5 枚で行う競技です。</li> <li>同じ数字のカードは 5 枚以上ありません。</li> <li>ジョーカーは無いものとします。</li> <li>以下のポーカーの役だけを考えるものとします。(番号が大きいほど役が高くなります。)</li> </ul> <ol style="margin-left:40px"> <li>役なし(以下に挙げるどれにも当てはまらない)</li> <li>ワンペア...
s074862730
p00039
Python
Accepted
272
20
5,564
dic = {"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000} while(True): try: lis = list(input()) ans = [dic[e] for e in lis] print(sum([-ans[i] if ans[i]<ans[i+1] else ans[i] for i in range(len(ans)-1)] + [ans[-1]])) except: break
IV CCCCLXXXXVIIII CDXCIX
4 499 499
<H1>ローマ数字</H1> <p> 古代ローマでは数を数えることは難しい仕事でした。アラビア数字の 0,1,2,3,…, 9 はまだ流布していませんでした。その代わり次のような記号が使われていました。 </p> <center> <table border=1> <tr> <td bgcolor="#EEFFFF" width="100">アラビア数字</td><td width="100">ローマ数字</td><td bgcolor="#EEFFFF" width="100">アラビア数字</td><td width="100">ローマ数字</td><td bgcolor="#EEFFFF" width="10...
s675410336
p00039
Python
Accepted
276
20
4,212
#!/usr/bin/env python # -*- coding: utf-8 -*- from sys import * lis = {"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000,"\n":0} for s in stdin: num = 0 for i in xrange(len(s)-1): if lis[s[i]] < lis[s[i+1]]: num -= lis[s[i]]; else: num += lis[s[i]] print num
IV CCCCLXXXXVIIII CDXCIX
4 499 499
<H1>ローマ数字</H1> <p> 古代ローマでは数を数えることは難しい仕事でした。アラビア数字の 0,1,2,3,…, 9 はまだ流布していませんでした。その代わり次のような記号が使われていました。 </p> <center> <table border=1> <tr> <td bgcolor="#EEFFFF" width="100">アラビア数字</td><td width="100">ローマ数字</td><td bgcolor="#EEFFFF" width="100">アラビア数字</td><td width="100">ローマ数字</td><td bgcolor="#EEFFFF" width="10...
s882681581
p00040
Python
Accepted
725
80
4,392
#!/usr/bin/env python # -*- coding: utf-8 -*- from itertools import * def code(a,b,st): v = "" for s in st: v += chr( ( a*(ord(s)-ord("a"))+ b ) % 26 + ord("a")) return v def invert(string,codelist): for st in string: v = "" for s in st: v += codelist[s] print v, def search(x,y,st): for e ...
1 y eazqyp pnop pngtg ye obmpngt xmybp mr lygw
i submit that there is another point of view
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>アフィン暗号</H1> <p> 簡単な暗号法の一つに、アフィン暗号というものがあり...
s439615127
p00040
Python
Accepted
1,207
30
6,776
import sys f = sys.stdin import string OFFSET = ord('a') def to_gamma(c): return ord(c) - OFFSET def from_gamma(gamma, alpha, beta): return chr((alpha * gamma + beta) % 26 + OFFSET) def affine(c, alpha, beta): return from_gamma(to_gamma(c), alpha, beta) # g[0]==g[3]である前提 def search_that(w): b = ...
1 y eazqyp pnop pngtg ye obmpngt xmybp mr lygw
i submit that there is another point of view
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }}); </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <H1>アフィン暗号</H1> <p> 簡単な暗号法の一つに、アフィン暗号というものがあり...
s069337243
p00043
Python
Accepted
1,006
30
5,608
def is_solved(nums): keys = set(nums) for key in keys: if nums.count(key) >= 2: tmp = nums[:] tmp.remove(key) tmp.remove(key) for key in keys: key_count = tmp.count(key) if key_count == 4: if key + 1 in tmp and key + 2 in tmp: for _ in range(4): tmp....
3649596966777 6358665788577 9118992346175 9643871425498 7755542764533 1133557799246
2 3 5 8 3 4 1 2 3 4 5 6 7 8 9 7 8 9 1 2 3 4 6 7 8 0
<H1>パズル</H1> <p> 1 〜 9 の数字を 14 個組み合わせて完成させるパズルがあります。与えられた 13 個の数字にもうひとつ数字を付け加えて完成させます。 </p> <p> パズルの完成条件は </p> <ul> <li>同じ数字を2つ組み合わせたものが必ずひとつ必要です。</li> <li>残りの12 個の数字は、3個の数字の組み合わせ4つです。<br> 3個の数字の組み合わせ方は、同じ数字を3つ組み合わせたものか、または3つの連続する数字を組み合わせたものです。ただし、9 1 2 のような並びは連続する数字とは認められません。</li> <li>同じ数字は4 回まで使えます。</li> </ul> ...
s911071232
p00043
Python
Accepted
1,806
60
4,328
import sys def pokakito(num_line): if not num_line and flag == 1: result_lis.append(check_num) return True for num in num_line: if three(num, num_line): return True if two(num, num_line): return True if straight(num, num_line): return True def three(num, num_line): ...
3649596966777 6358665788577 9118992346175 9643871425498 7755542764533 1133557799246
2 3 5 8 3 4 1 2 3 4 5 6 7 8 9 7 8 9 1 2 3 4 6 7 8 0
<H1>パズル</H1> <p> 1 〜 9 の数字を 14 個組み合わせて完成させるパズルがあります。与えられた 13 個の数字にもうひとつ数字を付け加えて完成させます。 </p> <p> パズルの完成条件は </p> <ul> <li>同じ数字を2つ組み合わせたものが必ずひとつ必要です。</li> <li>残りの12 個の数字は、3個の数字の組み合わせ4つです。<br> 3個の数字の組み合わせ方は、同じ数字を3つ組み合わせたものか、または3つの連続する数字を組み合わせたものです。ただし、9 1 2 のような並びは連続する数字とは認められません。</li> <li>同じ数字は4 回まで使えます。</li> </ul> ...
s234174829
p00044
Python
Accepted
336
30
6,636
from math import sqrt, ceil N = 53000 temp = [True]*(N+1) temp[0] = temp[1] = False for i in range(2, ceil(sqrt(N+1))): if temp[i]: temp[i+i::i] = [False]*(len(temp[i+i::i])) while True: try: n = int(input()) print(n-1-temp[n-1:0:-1].index(True), n+1+temp[n+1:].index(True)) except ...
19 3517
17 23 3511 3527
<H1>素数 II</H1> <p> 素数というのは、1 よりも大きくそれ自身か 1 でしか割りきれない整数をいいます。例えば、2 は、2 と 1 でしか割り切れないので素数ですが、12 は、12 と 1 のほかに、2, 3, 4, 6 で割りきれる数なので素数ではありません。 </p> <p> 整数 <var>n</var> を入力したとき、<var>n</var> より小さい素数のうち最も大きいものと、<var>n</var> より大きい素数のうち最も小さいものを出力するプログラムを作成してください。 </p> <H2>Input</H2> <p> 複数のデータセットが与えられます。各データセットに <var>n...
s304426598
p00044
Python
Accepted
509
20
5,656
import math def p_l(n): for i in range(n-1, 1, -1): flag=0 for j in range(2, int(math.sqrt(i)) + 1): if i % j == 0: flag=1 if flag==1:continue return i def p_h(n): for i in range(n+1,50022): flag=0 for j in range(2, int(math.sqrt(i)) + ...
19 3517
17 23 3511 3527
<H1>素数 II</H1> <p> 素数というのは、1 よりも大きくそれ自身か 1 でしか割りきれない整数をいいます。例えば、2 は、2 と 1 でしか割り切れないので素数ですが、12 は、12 と 1 のほかに、2, 3, 4, 6 で割りきれる数なので素数ではありません。 </p> <p> 整数 <var>n</var> を入力したとき、<var>n</var> より小さい素数のうち最も大きいものと、<var>n</var> より大きい素数のうち最も小さいものを出力するプログラムを作成してください。 </p> <H2>Input</H2> <p> 複数のデータセットが与えられます。各データセットに <var>n...
s900633684
p00045
Python
Accepted
221
20
5,608
n = 0 sum = 0 ave = 0 while(True): try: a,b = map(int,input().split(",")) sum += a*b ave += b n += 1 except EOFError: print(sum) print(int(ave/n+0.5)) break
100,20 50,10 70,35
4950 22
<H1>Sum and Average</H1> <p> 販売単価と販売数量を読み込んで、販売金額の総合計と販売数量の平均を出力するプログラムを作成してください。 </p> <H2>Input</H2> <p> 入力は以下の形式で与えられます。 </p> <pre> 販売単価,販売数量 販売単価,販売数量 : : </pre> <p> カンマで区切られた販売単価と販売数量の組が、複数行に渡って与えられます。入力される値はすべて 0 以上 1,000 以下で、販売単価と販売数量の組の数は 100 を超えません。 </p> <H2>Output</H2> <p> 1行目に販売金額の総合計(整数)、2行目に販売数量の平均...
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
3