submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s460827217
p00013
Accepted
s = [] while 1: try: n = input() if n==0: print s.pop() else: s.append(n) except EOFError: break;
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s049077135
p00013
Accepted
# -*- coding: utf-8 -*- import sys lineNumber = 0 #for line in [ "1", "6", "0", "8", "10", "0", "0", "0" ]: for line in sys.stdin.readlines(): lineNumber += 1 # except line if lineNumber == 1: cars = [] # get data List = map(int, line.strip().split()) n = List[0] if n == 0: print cars.pop() else : cars.append(n)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s196802599
p00013
Accepted
stuck = [] while True: try: x = int(raw_input()) if x == 0: go = stuck.pop() print go else: stuck.append(x) except: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s405341629
p00013
Accepted
stack = [] while True: try: num = input() if num == 0: print stack.pop() else: stack.append(num) except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s829495590
p00013
Accepted
import sys x=[] for n in map(int,sys.stdin): if n:x.append(n) else:print x.pop()
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s822766006
p00013
Accepted
import sys x=[] for n in map(int, sys.stdin): if n: x.append(n) else: print x.pop()
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s410539776
p00013
Accepted
import sys storage = [] for car in sys.stdin: car = int(car) if car > 0: storage.append(car) elif car == 0: print storage.pop() while storage: print storage.pop()
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s752610069
p00013
Accepted
cars = [] ans = [] while True: try: n = int(raw_input()) if n == 0: ans.append(cars.pop()) else: cars.append(n) except EOFError: for car in ans: print car break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s673058783
p00013
Accepted
L = [] while 1: try: n = input() if n == 0: print L.pop() else: L.append(n) except: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s394714238
p00013
Accepted
#!/usr/bin/env python # -*- coding:utf-8 -*- import sys i = 0 inn=[] for i in sys.stdin: i=int(i) if i==0 and len(inn)>0: print inn[-1] inn.pop() elif i==0 and len(inn)==0: sys.exit() elif i!=0: inn.append(i) for i in inn: print i
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s157865273
p00013
Accepted
try: a = [] while True: p = int(raw_input()) if p == 0: print a.pop() else: a.append(p) except: pass
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s483055657
p00013
Accepted
import sys stack = [] for n in sys.stdin: if int(n) == 0: print '%d'%int(stack.pop()) else: stack.append(n)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s167532957
p00013
Accepted
stack = [] while True: try: n = int(input()) except: break if n: stack.append(n) else: print(stack.pop())
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s056278146
p00013
Accepted
DE = [] while True: try: N = int(input()) except: break if N > 0: DE.insert(0,N) if N==0: print(DE[0]) DE.pop(0)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s549704061
p00013
Accepted
train = [] while True: try: tmp = int(input()) if tmp: train.append(tmp) else: print(train.pop()) except: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s609758274
p00013
Accepted
lst = [] stack = [] while True : try : lst.append(int(input())) except EOFError : break for i in lst : if i == 0 : print(stack.pop(-1)) else : stack.append(i)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s119640523
p00013
Accepted
from collections import deque d = deque() while True: try: n = int(input()) if n == 0: print(d.pop()) else: d.append(n) except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s664768903
p00013
Accepted
s = [] while 1: try: d = int(input()) except: break if d == 0: print(s.pop()) else: s.append(d)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s782969790
p00013
Accepted
try: num = [] while True: #標準入力 i = int(input()) #0だった場合1番後ろを出力し削除、それ以外はリストに追加 if i == 0: print(num[-1]) num.pop(-1) else:num.append(i) #EOFErrorをひろい、ループを抜ける except EOFError: pass
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s372496142
p00013
Accepted
a = [] while True: try: t = input() except: break if t == "0": print(a.pop()) else: a.append(t)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s531893942
p00013
Accepted
a = [] i = 0 while True: try: n = int(input()) if (n): a.append(n) i += 1 else: i -= 1 print(a[i]) a.pop() except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s751367097
p00013
Accepted
s = [] while 1: try: n = int(input()) if n == 0: print(s.pop()) else: s.append(n) except: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s396329856
p00013
Accepted
import sys numbers = [] try: while True: a = int(input()) if a != 0: numbers.append(a) elif a == 0: print(numbers.pop()) except Exception: sys.exit()
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s830128933
p00013
Accepted
a = [] while True: try: i = int(input()) except: break if i == 0: c = a.pop() print(c) else: a.append(i)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s897168448
p00013
Accepted
l1 = [] l2 = [] try: while(True): n = int(input()) if n == 0: l2.append(l1[-1]) del l1[-1] else: l1.append(n) except: pass for i in l2: print(i)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s466936295
p00013
Accepted
list=[] while True: try: n = int(input()) if n==0: print(list.pop()) else: list.append(n) except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s926319493
p00013
Accepted
from collections import deque q=deque([]) while True: try: n=int(input()) except: break if n==0: print(q.pop()) else: q.append(n)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s760554492
p00013
Accepted
D=[] while True: try: n=int(input()) if n==0: print(D.pop(-1)) else: D.append(n) except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s104072871
p00013
Accepted
from collections import deque cars=deque() while(True): try: n=int(input()) print(cars.popleft()) if n==0 else cars.appendleft(n) except: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s969290415
p00013
Accepted
if __name__ == '__main__': A = [] while True: try: n = int(input()) if n == 0: print(A[-1]) A.pop(-1) else: A.append(n) except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s305436560
p00013
Accepted
c = [] while True: try: n = int(input()) if n == 0: print(c.pop()) else: c.append(n) except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s822563956
p00013
Accepted
car = [] while True: try: x =int(input()) if x == 0: print(car.pop()) else: car.append(x) except:break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s554992517
p00013
Accepted
car = [] while 1: try: i = int(input()) if i == 0: print(car.pop()) else: car.append(i) except ValueError: print(car) for j in range(len(car)): print(car.pop()) break except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s817568743
p00013
Accepted
cars = [] while True: try: inVal = int(input()) if inVal == 0: print(cars.pop(-1)) else: cars.append(inVal) except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s339741573
p00013
Accepted
import sys stack = [] for line in sys.stdin: n = int(line) if n == 0: print stack.pop(-1) else: stack.append(n)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s837621495
p00013
Accepted
car=[] while True: try: n=int(input()) if n!=0: car.append(n) else: print(car.pop()) except:break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s842738256
p00013
Accepted
stack = [] while True: try: num = int(input()) except EOFError: break if num != 0: stack.append(num) elif num == 0: print(stack.pop(-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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s457039850
p00013
Accepted
import sys stack = [] for nstr in sys.stdin: n = int(nstr) if n == 0: print(stack.pop()) else: stack.append(n)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s820282735
p00013
Accepted
list1 = [] for i in range(1, 200): try: str1 = input() if str1 != '0' and str1 != '': list1.append(str1) elif str1 == '0': print(list1.pop()) else: break except: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s570122350
p00013
Accepted
stack = [] while True: try: data = int(input()) if data == 0: print stack.pop() else: stack.append(data) except: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s345633414
p00013
Accepted
if __name__ == '__main__': lst = [] while True: try: n = int(input()) if n == 0: print (lst.pop()) else: lst.append(n) except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s248724143
p00013
Accepted
x = [] while(1): try: a = int(input()) if a == 0: print(x[-1]) x.pop(len(x)-1) # if len(x) == 0: # break else: x.append(a) except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s907604285
p00013
Accepted
stack = [] while True: try: i = input() if i == "0": print(stack.pop(0)) else: stack.insert(0, i) except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s689717419
p00013
Accepted
l = [] while(1): try: n = int(input()) except: break if n == 0: ans = l.pop(-1) print(ans) else: l.append(n)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s373348438
p00013
Accepted
li = [] while True: try: n = int(input()) except: break if n == 0: print(li.pop()) else: li.append(n)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s295981583
p00013
Accepted
ans = [] while True: try: x = int(input()) if x == 0: print(ans.pop()) else: ans.append(x) except: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s973314044
p00013
Accepted
ar = [] while(True): try: n = int(input()) if n == 0: print(ar.pop()) else: ar.append(n) except: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s062037067
p00013
Accepted
q = [] while True: try: i = int(input()) if i == 0: print(q.pop()) else: q.append( i ) except: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s224680641
p00013
Accepted
waits=[] while 1: try: i=input() if i=="0": print(waits[-1]) waits.pop() else: waits.append(i) except:break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s490696524
p00013
Accepted
from collections import deque import sys train = deque([]) for line in sys.stdin: n = int(line) if n == 0: t = train.popleft() print(t) else: train.appendleft(n)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s245053271
p00013
Accepted
nlist = [] while 1: try: n = int(input()) if n == 0: print(nlist.pop(-1)) else: nlist.append(n) except: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s632508416
p00013
Accepted
import sys def main(): stack = [] for x in sys.stdin: x = int(x) if x: stack.append(x) else: print(stack.pop()) if __name__ == '__main__': main()
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s896902403
p00013
Accepted
# Switching Railroad Cars from collections import deque num = int(input()) stk = deque() while 1: if num == 0: print(stk.pop()) else: stk.append(num) try: num = int(input()) except EOFError: break while stk: print(stk.pop())
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s972301940
p00013
Runtime Error
#!/usr/bin/env python # -*- coding: utf-8 -*- lis = [] while True: d = input() if d == 0: print lis[-1] lis.pop() else: lis.append(d)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s738803340
p00013
Runtime Error
import sys cars = [] for line in sys.stdin: car = int(line) if car: cars.append(num) else: print(cars.pop())
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s294895272
p00013
Runtime Error
garage = [] while True: num = int(input()) if num == 0: print(garage.pop()) else: garage.append(num)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s181752995
p00013
Runtime Error
rail = [] while True: n = int(raw_input()) if n != 0: rail.append(n) else: print rail.pop()
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s027542509
p00013
Runtime Error
a = [] while True: s = int(input()) if s != 0: a.append(s) else: print(a.pop())
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s238079270
p00013
Runtime Error
list=[] list.append(input()) While list!=[]: inp=input() if inp==0: print list[-1] del list[-1] else: list.append(inp)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s769178291
p00013
Runtime Error
lis=[] lis.append(input()) while True: inp=input() if inp==0: print lis[-1] del lis[-1] else: lis.append(inp)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s279322457
p00013
Runtime Error
lis=[] lis.append(input()) while true: inp=input() if inp==0: print lis[-1] del lis[-1] else: lis.append(inp)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s116051221
p00013
Runtime Error
import sys s=[input()] while(True): n=input() if n=="0": print(s.pop()) elif n=="": sys.exit() else: s.append(n)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s382675037
p00013
Runtime Error
import sys s=[int(input())] while(True): n=input() if n=="0": print(s.pop()) elif n=="": sys.exit() else: s.append(int(n))
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s304095546
p00013
Runtime Error
# coding:utf-8 syako = [] number = input() while True: if number != 0: syako.append(number) elif number == 0: print syako.pop() number = input() if number == EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s778374543
p00013
Runtime Error
while True: try: n = int(input()) except: break arr = [] if n == 0: print(arr[-1]) arr = arr[:-1] else: arr.append(n)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s531654260
p00013
Runtime Error
import sys cars = list() for line in sys.stdin.readlines(): line = line.strip() N = int(line) if N != 0: cars.append(N) else: print cars.pop()
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s667763218
p00013
Runtime Error
import sys cars = list() for line in sys.stdin.readlines(): line = line.strip() N = int(line) if N != 0: cars.append(N) else: print(cars.pop())
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s871888014
p00013
Runtime Error
import sys cars = list() for line in sys.stdin.readlines(): line = line.strip() print line N = int(line) if N != 0: cars.append(N) else: print(cars.pop())
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s672251385
p00013
Runtime Error
import sys stack = list() for line in sys.stdin.readlines(): line = line.strip() n = int(line) if n == 0: print stack.pop() else: stack.append(n)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s158627240
p00013
Runtime Error
import sys lst = [] for line in sys.stdin: num = int(line) if num == 0: print lst.pop() else: lst.append(num)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s627778925
p00013
Runtime Error
import sys lst = [] for line in sys.stdin: num = int(line.split()) if num == 0: print lst.pop() else: lst.append(num) sys.exit(0)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s248530839
p00013
Runtime Error
import sys lst = [] for line in sys.stdin: num = int(line.strip()) if num == 0: print lst.pop() else: lst.append(num)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s986480804
p00013
Runtime Error
import sys list=[] for i in sys.stdin.readlines(): if int(i) != 0: list.append(int(i)) else: print list.pop()
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s478791522
p00013
Runtime Error
import sys list=[] for i in sys.stdin.readlines(): if float(i) != 0: list.append(float(i)) else: print int(list.pop())
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s174292492
p00013
Runtime Error
import sys stack=[] for i in sys.stdin: a=int(i) if a >0 : stack.append(a) else : print stack.pop()
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s551204634
p00013
Runtime Error
# -*- coding: utf-8 -*- import sys stack=[] for i in sys.stdin: a=int(i.split('\n')[0]) if a >0 : stack.append(a) else : print stack.pop()
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s815866707
p00013
Runtime Error
tracks = [] while 1: try: c = input() if c == 0: print tracks.pop() else: tracks.append(c) except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s314927296
p00013
Runtime Error
tracks = [] while 1: try: c = int(raw_input()) if c == 0: print tracks.pop() else: tracks.append(c) except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s015296118
p00013
Runtime Error
tracks = [] while 1: try: c0 = raw_input() c = int(c0) if c == 0: print tracks.pop() else: tracks.append(c) except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s340202473
p00013
Runtime Error
from collections import deque garage = deque() while True: try: came = int(raw_input()) if came == 0: print garage.pop() else: garage.append(came) except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s455975337
p00013
Runtime Error
from collections import deque garage = deque() while True: try: came = int(raw_input()) if came == 0: print garage.pop() if len(garage) == 0: break else: garage.append(came)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s913346033
p00013
Runtime Error
l = [] while True: try: train = int(raw_input()) if train == 0: print(l.pop()) else: l.append(train) except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s960764655
p00013
Runtime Error
ans = [] while True: try: a = input() if a != 0: ans.append(a) elif a == 0: print ans[-1] del ans[-1] except EOFError: break
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s254471157
p00013
Runtime Error
from __future__ import (division, absolute_import, print_function, unicode_literals) from sys import stdin L = [] for line in stdin: n = int(line) if not n: print(L.pop()) else: L.append(n)
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s049539444
p00013
Runtime Error
ans=[] cars=[] while True: try: n=input() except EOFError: break if not n: ans.append(cars.pop()) else: cars.append(n) for i in ans: print i
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s723389396
p00013
Runtime Error
ans=[] cars=[] while True: try: n=input() except EOFError: break if not n: out=cars.pop() ans.append(out) else: cars.append(n) for i in ans: print i
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s655881689
p00013
Runtime Error
bottom = [] while True: carnum = input() if carnum == '': break elif carnum == 0: bottom.pop() continue else: nottom.append(carnum) continue
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 track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. </p> <p> We can simulate the movement (comings and goings) of the cars as follow: </p> <ul> <li>An entry of a car is represented by its number.</li> <li>An exit of a car is represented by 0</li> </ul> <p> For example, a sequence </p> <pre> 1 6 0 8 10 </pre> <p> demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. </p> <p> Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks. </p> <H2>Input</H2> <pre> car number car number or 0 car number or 0 . . . car number or 0 </pre> <p> The number of input lines is less than or equal to 100. </p> <H2>Output</H2> <p> For each 0, print the car number. </p> <H2>Sample Input</H2> <pre> 1 6 0 8 10 0 0 0 </pre> <H2>Output for the Sample Input</H2> <pre> 6 10 8 1 </pre>
s745806562
p00014
Wrong Answer
import sys X = 600 for line in sys.stdin: s=0 d = int(line) for nowx in xrange(0,X,d): s += d*(nowx**2) print nowx print s
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 computes the area of a shape represented by the following three lines:<br/> <br/> $y = x^2$<br/> $y = 0$<br/> $x = 600$<br/> <br/> <!--<center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF1"></center>--> </p> <p> It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure: </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integral"><br/> $f(x) = x^2$<br/> <br/> </center> <!-- <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF2"> </center> --> <p> The approximative area $s$ where the width of the rectangles is $d$ is:<br/> <br/> area of rectangle where its width is $d$ and height is $f(d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(2d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(3d)$ $+$ <br/> ...<br/> area of rectangle where its width is $d$ and height is $f(600 - d)$ <br/> </p> <p> The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$. </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20. </p> <H2>Output</H2> <p> For each dataset, print the area $s$ in a line. </p> <H2>Sample Input</H2> <pre> 20 10 </pre> <H2>Output for the Sample Input</H2> <pre> 68440000 70210000 </pre>
s923041965
p00014
Wrong Answer
def function(a): s=0 d=a for i in range(d,600-d+1,d): s+=a*(d**2) d+=a #print("%10d %10d"%(d,s)) return s n=int(input()) print(function(n))
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 computes the area of a shape represented by the following three lines:<br/> <br/> $y = x^2$<br/> $y = 0$<br/> $x = 600$<br/> <br/> <!--<center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF1"></center>--> </p> <p> It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure: </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integral"><br/> $f(x) = x^2$<br/> <br/> </center> <!-- <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF2"> </center> --> <p> The approximative area $s$ where the width of the rectangles is $d$ is:<br/> <br/> area of rectangle where its width is $d$ and height is $f(d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(2d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(3d)$ $+$ <br/> ...<br/> area of rectangle where its width is $d$ and height is $f(600 - d)$ <br/> </p> <p> The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$. </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20. </p> <H2>Output</H2> <p> For each dataset, print the area $s$ in a line. </p> <H2>Sample Input</H2> <pre> 20 10 </pre> <H2>Output for the Sample Input</H2> <pre> 68440000 70210000 </pre>
s133283777
p00014
Wrong Answer
d = int(input()) s = 0 for n in [i * d for i in range(1, 600)]: if n >= 600: break s += (n ** 2) print(s * d)
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 computes the area of a shape represented by the following three lines:<br/> <br/> $y = x^2$<br/> $y = 0$<br/> $x = 600$<br/> <br/> <!--<center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF1"></center>--> </p> <p> It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure: </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integral"><br/> $f(x) = x^2$<br/> <br/> </center> <!-- <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF2"> </center> --> <p> The approximative area $s$ where the width of the rectangles is $d$ is:<br/> <br/> area of rectangle where its width is $d$ and height is $f(d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(2d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(3d)$ $+$ <br/> ...<br/> area of rectangle where its width is $d$ and height is $f(600 - d)$ <br/> </p> <p> The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$. </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20. </p> <H2>Output</H2> <p> For each dataset, print the area $s$ in a line. </p> <H2>Sample Input</H2> <pre> 20 10 </pre> <H2>Output for the Sample Input</H2> <pre> 68440000 70210000 </pre>
s792278532
p00014
Wrong Answer
print('test')
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 computes the area of a shape represented by the following three lines:<br/> <br/> $y = x^2$<br/> $y = 0$<br/> $x = 600$<br/> <br/> <!--<center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF1"></center>--> </p> <p> It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure: </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integral"><br/> $f(x) = x^2$<br/> <br/> </center> <!-- <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF2"> </center> --> <p> The approximative area $s$ where the width of the rectangles is $d$ is:<br/> <br/> area of rectangle where its width is $d$ and height is $f(d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(2d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(3d)$ $+$ <br/> ...<br/> area of rectangle where its width is $d$ and height is $f(600 - d)$ <br/> </p> <p> The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$. </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20. </p> <H2>Output</H2> <p> For each dataset, print the area $s$ in a line. </p> <H2>Sample Input</H2> <pre> 20 10 </pre> <H2>Output for the Sample Input</H2> <pre> 68440000 70210000 </pre>
s635806764
p00014
Wrong Answer
import sys a = [] for line in sys.stdin: a.append(line) for n in a: num=int(n) x=0 are=0 while x<600: are+=(x**2)*num x+=num print are
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 computes the area of a shape represented by the following three lines:<br/> <br/> $y = x^2$<br/> $y = 0$<br/> $x = 600$<br/> <br/> <!--<center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF1"></center>--> </p> <p> It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure: </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integral"><br/> $f(x) = x^2$<br/> <br/> </center> <!-- <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF2"> </center> --> <p> The approximative area $s$ where the width of the rectangles is $d$ is:<br/> <br/> area of rectangle where its width is $d$ and height is $f(d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(2d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(3d)$ $+$ <br/> ...<br/> area of rectangle where its width is $d$ and height is $f(600 - d)$ <br/> </p> <p> The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$. </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20. </p> <H2>Output</H2> <p> For each dataset, print the area $s$ in a line. </p> <H2>Sample Input</H2> <pre> 20 10 </pre> <H2>Output for the Sample Input</H2> <pre> 68440000 70210000 </pre>
s789377090
p00014
Wrong Answer
d=int(input()) sum=0 for i in range(int(600/d)): sum+=(((i*d)**2)*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 computes the area of a shape represented by the following three lines:<br/> <br/> $y = x^2$<br/> $y = 0$<br/> $x = 600$<br/> <br/> <!--<center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF1"></center>--> </p> <p> It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure: </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integral"><br/> $f(x) = x^2$<br/> <br/> </center> <!-- <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF2"> </center> --> <p> The approximative area $s$ where the width of the rectangles is $d$ is:<br/> <br/> area of rectangle where its width is $d$ and height is $f(d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(2d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(3d)$ $+$ <br/> ...<br/> area of rectangle where its width is $d$ and height is $f(600 - d)$ <br/> </p> <p> The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$. </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20. </p> <H2>Output</H2> <p> For each dataset, print the area $s$ in a line. </p> <H2>Sample Input</H2> <pre> 20 10 </pre> <H2>Output for the Sample Input</H2> <pre> 68440000 70210000 </pre>
s816128702
p00014
Wrong Answer
def integral(d): print("d=%d" % d) n = 600//d print("n=%d" % n) s = 0.0 for i in range(n): s += (d*i)**2 return(s*d) if __name__ == '__main__': while True: try: d = int(input()) print(int(integral(d))) except: break
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 computes the area of a shape represented by the following three lines:<br/> <br/> $y = x^2$<br/> $y = 0$<br/> $x = 600$<br/> <br/> <!--<center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF1"></center>--> </p> <p> It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure: </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integral"><br/> $f(x) = x^2$<br/> <br/> </center> <!-- <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF2"> </center> --> <p> The approximative area $s$ where the width of the rectangles is $d$ is:<br/> <br/> area of rectangle where its width is $d$ and height is $f(d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(2d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(3d)$ $+$ <br/> ...<br/> area of rectangle where its width is $d$ and height is $f(600 - d)$ <br/> </p> <p> The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$. </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20. </p> <H2>Output</H2> <p> For each dataset, print the area $s$ in a line. </p> <H2>Sample Input</H2> <pre> 20 10 </pre> <H2>Output for the Sample Input</H2> <pre> 68440000 70210000 </pre>
s712491914
p00014
Wrong Answer
import sys def f(x): return x ** 2 def integral(d): s = f(d) * d for i in range(600 // d - 1): s += f(d * (i + 1)) * d return s lines = sys.stdin.readlines() for line in lines: print(integral(int(line)))
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 computes the area of a shape represented by the following three lines:<br/> <br/> $y = x^2$<br/> $y = 0$<br/> $x = 600$<br/> <br/> <!--<center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF1"></center>--> </p> <p> It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure: </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integral"><br/> $f(x) = x^2$<br/> <br/> </center> <!-- <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF2"> </center> --> <p> The approximative area $s$ where the width of the rectangles is $d$ is:<br/> <br/> area of rectangle where its width is $d$ and height is $f(d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(2d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(3d)$ $+$ <br/> ...<br/> area of rectangle where its width is $d$ and height is $f(600 - d)$ <br/> </p> <p> The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$. </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20. </p> <H2>Output</H2> <p> For each dataset, print the area $s$ in a line. </p> <H2>Sample Input</H2> <pre> 20 10 </pre> <H2>Output for the Sample Input</H2> <pre> 68440000 70210000 </pre>
s439228915
p00014
Wrong Answer
import sys for line in sys.stdin: d = int(line) S = 0 for x in range(1, 600, d): S += (x ** 2) * d print(S)
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 computes the area of a shape represented by the following three lines:<br/> <br/> $y = x^2$<br/> $y = 0$<br/> $x = 600$<br/> <br/> <!--<center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF1"></center>--> </p> <p> It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure: </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integral"><br/> $f(x) = x^2$<br/> <br/> </center> <!-- <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF2"> </center> --> <p> The approximative area $s$ where the width of the rectangles is $d$ is:<br/> <br/> area of rectangle where its width is $d$ and height is $f(d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(2d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(3d)$ $+$ <br/> ...<br/> area of rectangle where its width is $d$ and height is $f(600 - d)$ <br/> </p> <p> The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$. </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20. </p> <H2>Output</H2> <p> For each dataset, print the area $s$ in a line. </p> <H2>Sample Input</H2> <pre> 20 10 </pre> <H2>Output for the Sample Input</H2> <pre> 68440000 70210000 </pre>
s203079084
p00014
Wrong Answer
d = int(input()) print(sum(d * (i ** 2) for i in range(int(600/d))))
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 computes the area of a shape represented by the following three lines:<br/> <br/> $y = x^2$<br/> $y = 0$<br/> $x = 600$<br/> <br/> <!--<center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF1"></center>--> </p> <p> It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure: </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integral"><br/> $f(x) = x^2$<br/> <br/> </center> <!-- <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF2"> </center> --> <p> The approximative area $s$ where the width of the rectangles is $d$ is:<br/> <br/> area of rectangle where its width is $d$ and height is $f(d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(2d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(3d)$ $+$ <br/> ...<br/> area of rectangle where its width is $d$ and height is $f(600 - d)$ <br/> </p> <p> The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$. </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20. </p> <H2>Output</H2> <p> For each dataset, print the area $s$ in a line. </p> <H2>Sample Input</H2> <pre> 20 10 </pre> <H2>Output for the Sample Input</H2> <pre> 68440000 70210000 </pre>
s103836703
p00014
Wrong Answer
d = int(input()) print(sum(d * ((i * d) ** 2) for i in range(int(600/d))))
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 computes the area of a shape represented by the following three lines:<br/> <br/> $y = x^2$<br/> $y = 0$<br/> $x = 600$<br/> <br/> <!--<center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF1"></center>--> </p> <p> It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure: </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integral"><br/> $f(x) = x^2$<br/> <br/> </center> <!-- <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF2"> </center> --> <p> The approximative area $s$ where the width of the rectangles is $d$ is:<br/> <br/> area of rectangle where its width is $d$ and height is $f(d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(2d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(3d)$ $+$ <br/> ...<br/> area of rectangle where its width is $d$ and height is $f(600 - d)$ <br/> </p> <p> The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$. </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20. </p> <H2>Output</H2> <p> For each dataset, print the area $s$ in a line. </p> <H2>Sample Input</H2> <pre> 20 10 </pre> <H2>Output for the Sample Input</H2> <pre> 68440000 70210000 </pre>
s452124515
p00014
Wrong Answer
# AOJ 0014 Integral # Python3 2018.6.10 bal4u import sys for d in sys.stdin: print(sum(x**2 for x in range(int(d), 600, int(d))))
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 computes the area of a shape represented by the following three lines:<br/> <br/> $y = x^2$<br/> $y = 0$<br/> $x = 600$<br/> <br/> <!--<center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF1"></center>--> </p> <p> It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure: </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integral"><br/> $f(x) = x^2$<br/> <br/> </center> <!-- <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF2"> </center> --> <p> The approximative area $s$ where the width of the rectangles is $d$ is:<br/> <br/> area of rectangle where its width is $d$ and height is $f(d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(2d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(3d)$ $+$ <br/> ...<br/> area of rectangle where its width is $d$ and height is $f(600 - d)$ <br/> </p> <p> The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$. </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20. </p> <H2>Output</H2> <p> For each dataset, print the area $s$ in a line. </p> <H2>Sample Input</H2> <pre> 20 10 </pre> <H2>Output for the Sample Input</H2> <pre> 68440000 70210000 </pre>
s454723551
p00014
Wrong Answer
def f(x): return x**2 area = [] while 1: try: d0 = raw_input() if d0 == '': break d = int(d0) for i in range(d, 600, d): print i area.append(d*f(i)) print area Sumpoyo = sum(area) print Sumpoyo except EOFError: break
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 computes the area of a shape represented by the following three lines:<br/> <br/> $y = x^2$<br/> $y = 0$<br/> $x = 600$<br/> <br/> <!--<center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF1"></center>--> </p> <p> It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure: </p> <center><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integral"><br/> $f(x) = x^2$<br/> <br/> </center> <!-- <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_integralF2"> </center> --> <p> The approximative area $s$ where the width of the rectangles is $d$ is:<br/> <br/> area of rectangle where its width is $d$ and height is $f(d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(2d)$ $+$ <br/> area of rectangle where its width is $d$ and height is $f(3d)$ $+$ <br/> ...<br/> area of rectangle where its width is $d$ and height is $f(600 - d)$ <br/> </p> <p> The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$. </p> <H2>Input</H2> <p> The input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20. </p> <H2>Output</H2> <p> For each dataset, print the area $s$ in a line. </p> <H2>Sample Input</H2> <pre> 20 10 </pre> <H2>Output for the Sample Input</H2> <pre> 68440000 70210000 </pre>