submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s791541850
p04048
Accepted
N,X=map(int,input().split()) def f(x,y): if x%y==0: return y*(2*x//y-1) else: res=0 res=y*2*(x//y)+f(y,x%y) return res print(f(N-X,X)+N)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s884059171
p04048
Accepted
n,x = map(int,input().split()) res = n a = x #横 b = n-x #縦 while True: if a == b: res += a break elif a > b: k = a//b c = a%b if c == 0: res += (2*k-1)*b break else: res += 2*k*b a = c else: k = b//a ...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s363393018
p04048
Accepted
"""取込""" n, x = [int(i) for i in input().split(" ")] """問題""" def f(a, b): # print("({0}, {1})".format(a, b)) l = max(a, b) s = min(a, b) if s == 0: return -l else: return (l // s) * s * 2 + f(l % s, s) d = n + f(n - x, x) """出力""" print(d)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s884455198
p04048
Accepted
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return map(int, stdin.readline().split()) def li_(): return map(lambda x: int(x)-1, stdin.readline().split()) def lf(): return map(float, stdin.readline().split()) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() d...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s746930840
p04048
Accepted
N,X = map(int,input().split()) a,b = X,N-X if a > b: a,b = b,a ans = a+b while b%a: ans += b//a * (2*a) a,b = b%a, a ans += b//a * (2*a) - a print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s823058640
p04048
Accepted
N, X = [int(i) for i in input().split()] def gcd(a,b): if b == 0: return a return gcd(b,a%b) scale = gcd(N, X) print(scale*(N//scale-1)*3)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s560410529
p04048
Accepted
N, X = [int(elem) for elem in input().split()] total_distance = N bigger, smaller = N - X, X while bigger % smaller != 0: total_distance += 2 * (bigger // smaller) * smaller bigger, smaller = smaller, bigger % smaller total_distance += 2 * (bigger // smaller) * smaller - smaller print(total_distance)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s672198626
p04048
Accepted
from fractions import gcd n,m=map(int,input().split()) print(3*(n-gcd(n,m)))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s031128088
p04048
Accepted
ai = lambda: list(map(int,input().split())) n, x = ai() from fractions import gcd print(3*(n-gcd(n,x)))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s208964137
p04048
Accepted
n,x = map(int,input().split()) import fractions print(3 * (n-fractions.gcd(n,x)))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s653436499
p04048
Accepted
N, X = map(int, input().split()) ans = N a, b = min(X, N - X), max(X, N - X) while b % a: ans += 2 * (b // a) * a a, b = b % a, a ans += 2 * b // a * a - a print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s388561573
p04048
Accepted
n, x = map(int, input().split()) ans = n longer = max(x, n-x) shorter = min(x, n-x) while True: m = longer // shorter l = longer % shorter ans += m*shorter*2 if l == 0: ans -= shorter break longer = shorter shorter = l print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s992938186
p04048
Accepted
from fractions import gcd N,X = map(int,input().split()) print(3*(N-gcd(N,X)))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s373477549
p04048
Accepted
# coding:utf-8 def inpl(): return list(map(int, input().split())) n, x = inpl() def func(a, b): if a < b: a, b = b, a if a == b: return a else: if a % b == 0: return (a // b * 2 - 1) * b else: q, mod = divmod(a, b) return 2 * q * b + ...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s106788899
p04048
Accepted
N, X = map(int, input().split()) path = N a, b = X, N - X if a < b: a, b = b, a while b > 0: path += b * (a // b) * 2 a, b = b, a % b path -= a print(path)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s016479656
p04048
Accepted
n, x = map(int, input().split()) ans = n n -= x while n % x != 0: ans += 2 * (n // x) * x n , x = x, n % x ans += 2 * (n // x) * x - x print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s517756109
p04048
Accepted
def gcd(a, b): if a < b: a, b = b, a if b == 0: return a c = a % b return gcd(b, c) [N, X] = list(map(int, input().split())) print(int(3*(N-gcd(N,X))))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s381472602
p04048
Accepted
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s678449031
p04048
Accepted
N,X=map(int,input().split()) D=N L=N-X S=X if N==2*X: D=3*X else: for i in range(100): if L%S==0: D=D+(2*S)*(L//S)-S break else: D=D+(2*S)*(L//S) A=L B=S L=B S=A%B #print(D) print(D)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s925701277
p04048
Accepted
N, X = map(int, input().split()) ans = N if X >= N - X: a, b = X, N - X else: a, b = N - X, X while b > 0: ans += (a // b) * b * 2 a, b = b, a % b ans -= a print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s097083462
p04048
Accepted
n, x = map(int, input().split()) def func(a, b): if a < b: if b%a == 0: return (b//a*2 - 1)*a else: q, mod = divmod(b,a) return 2*q*a + func(a, mod) elif a > b: if a%b == 0: return (a//b*2 - 1)*b else: q, mod = divmod(a...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s329117493
p04048
Accepted
N, X = map(int, input().split()) def calc(d, c): q, m = divmod(d, c) if m == 0: return (2*q-1)*c else: return calc(c, m) + 2*q*c print(N + calc(X, N-X))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s744869889
p04048
Accepted
import sys import heapq sys.setrecursionlimit(10**8) #最大公約数 def gcd(a,b): while b: a,b = b, a%b return a #最小公倍数 def lcm(a,b): return a*b // gcd(a,b) N,X = map(int,input().split()) ans = N a = min(X,N-X) b = max(X,N-X) while True: #a<b n = b//a ans += n * 2 * a if n*a == b: ans -= a print(ans) ...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s564847838
p04048
Accepted
#!/usr/bin/env python3 import sys, math, copy # import fractions, itertools # import numpy as np # import scipy # sys.setrecursionlimit(1000000) HUGE = 2147483647 HUGEL = 9223372036854775807 ABC = "abcdefghijklmnopqrstuvwxyz" def gcd(x, y): if x < y: x, y = y, x # x >= y while y > 0: r = x %...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s957171132
p04048
Accepted
#!/usr/bin/env python3 import sys def debug(*args): print(*args, file=sys.stderr) def exit(): sys.exit(0) sys.setrecursionlimit(100000) N, X = map(int, input().split()) def f(x, n): if x == 0 or x == n: return 0 debug(x,n) # if 2*x == n: # return 3*x if x % (n-x) == 0: return ...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s904246473
p04048
Accepted
from fractions import gcd N, X = map(int, input().split()) print(3 * (N - gcd(N, X)))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s081706181
p04048
Accepted
lst=list(map(int,input().split())) #x n-x x x n-2x n-2x n-2x n=lst[0] x=lst[1] #if x==n-x : # s= if n-x<=x: a,b=x,n-x else: a,b= n-x,x s=n #i=0 while b!=0: s+=a//b*2*b c=a a=b b=c%b print(s-a)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s059483215
p04048
Accepted
N,X = map(int,input().split()) a = X b = N-X ans = a+b while b: d,m = divmod(a,b) ans += d*b*2 a,b = b,m print(ans - a)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s815408788
p04048
Accepted
n,x = (int(i) for i in input().split()) ans,a,b = n,x,n-x while a%b!=0: ans,a,b = ans+(a//b)*2*b,b,a%b print(ans+2*a-b)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s323609056
p04048
Accepted
n, x = input().split() n = int(n) x = int(x) ans = 0 a1, a2 = x, n - x l = min(a1, a2) h = max(a1, a2) while True: d = h // l ans += 3 * l * d temp = h - l * d if temp == 0: break h = l l = temp print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s352094560
p04048
Accepted
n, x = map(int, input().split()) def aaa(a,b): n = max(a,b) m = min(a,b) if n % m == 0: return 2 * n - m else: return 2 * m * int(n / m) + aaa(m, n % m) ans = n + aaa(n-x, x) print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s493921773
p04048
Accepted
n,x=map(int,input().split()) def solve(a,b): mi=min(a,b) ma=max(a,b) if ma%mi==0: return (ma//mi*2-1)*mi else: return (ma//mi*2)*mi+solve(mi,ma%mi) ans=n+solve(n-x,x) print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s230428310
p04048
Accepted
def gcd(a,b): if a%b==0: return b else: return gcd(b,a%b) N,X=map(int,input().split()) print(3*(N-gcd(N,X)))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s026325424
p04048
Accepted
N, X = map(int, input().split()) def gcd(a, b): while b: a, b = b, a % b return a print(3*(N - gcd(N, X)))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s908752596
p04048
Accepted
def gcd(a, b): while a != b: if a == 0: return b elif b == 0: return a if a > b : a %= b else: b %= a return a N, X=map(int, input().split()) ...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s564873080
p04048
Accepted
def solve(x, y): a = max(x, y) b = min(x, y) if b == 0: return 0 res = 2*a r = solve(b-a % b, a % b) if r == 0: res -= b res += r return res s = raw_input().split() n = int(s[0]) x = int(s[1]) ans = n + solve(x, n-x) print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s042058788
p04048
Accepted
def calc(a, b): if a <= 0 or b <= 0: return 0 if a == b: return a a, b = min(a, b), max(a, b) x = max(1, b / (2 * a)) return calc(b-x*a, a) + 2 * a * x N, X = map(int, raw_input().split()) print calc(X, N-X) + N
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s227580815
p04048
Accepted
n, x = map(int, raw_input().split()) a, b, result = x, n - x, n while b != 0: result += 2 * (a // b) * b a, b = b, a % b print result - a
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s517694570
p04048
Accepted
n, x = map(int, raw_input().split()) z = n y = n - x while y > 0: z += x / y * y * 2 x, y = y, x % y print z - x
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s389930173
p04048
Accepted
from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from fractions import gcd from bisect import bisect, bisect_left, bisect_right INF = 10 ** 10 def main(): N, X = map(int, input().split()) ...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s995869480
p04048
Accepted
def f(a, b): if a * b == 0: return 0 res = f(min(a, b), max(a, b) % min(a, b)) + 2 * min(a, b) * (max(a,b)//min(a, b)) if(max(a, b) % min(a, b) == 0): res -= min(a, b) return res n, x = map(int, input().split()) res = n + f(n - x, x) print(res)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s401564889
p04048
Accepted
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 gosa = 1.0 / 10**10 mod = 10**9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def L...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s618834486
p04048
Accepted
#!/usr/bin/env python3 def f(n, x): if n % x == 0: return (n // x * 2 - 1) * x else: return (n // x * 2) * x + f(x, n % x) n, x = map(int,input().split()) ans = n + f(n - x, x) print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s529184544
p04048
Accepted
def gcd(a,b): if b == 0: return a return gcd(b,a%b) N,k = map(int,raw_input().split()) #k = int(raw_input()) #A = map(int, raw_input().split()) ans = gcd(N,k) print 3*(N - ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s085880238
p04048
Accepted
def solve(a,b): a,b = max(a,b),min(a,b) if b == 0: return 0 res = 2*a r = solve(b-a%b, a%b) if r == 0: res -= b res += r return res n,x = map(int, raw_input().split()) ans = n + solve(x, n-x) print ans
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s206389156
p04048
Accepted
#ABC001B def gcd(a, b): while b: a, b = b, a % b return a n,x=map(int,raw_input().split()) res=3*(n-gcd(n,x)) print res
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s467097889
p04048
Accepted
n,x=map(int,raw_input().split()) def gcd(i,j): if j==0:return i else:return gcd(j,i%j) print 3*(n-gcd(n,x))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s146543167
p04048
Accepted
def read(): return [int(i) for i in input().split(" ")] def calculate(x, y): if(y % x == 0): return x * (2 * (y / x) - 1) else: return x * 2 * (y // x) + calculate(y % x, x) (N, X) = read() length = N + calculate(X, N - X) print(int(length))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s999658450
p04048
Accepted
calculate_remainder=lambda pl,pr:2*(pl//pr)*pr-pr if pl%pr==0 else 2*(pl//pr)*pr+calculate_remainder(pr,pl%pr) n,k=(int(s) for s in input().strip().split(' ')) print(str(n+calculate_remainder(n-k,k)))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s973444796
p04048
Accepted
NX = input() NX = "".join(NX).split(" ") NX = [int(s) for s in NX] N =NX[0] X =NX[1] D = NX[0]-NX[1] A=X+D def ans(x,y): global A if x%y==0: A+=2*y*(x/y)-y return print(int(A)) A +=int(x/y)*y*2 ans(y,x%y) if X>D: ans(X,D) else: ans(D,X)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s159971476
p04048
Accepted
from sys import stdin n,k = map(int,stdin.readline().split()) def gcd(a,b): while a%b: t = a%b; a=b; b=t return b print (n-gcd(n,k))*3
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s271494491
p04048
Accepted
N, x = [int(s) for s in input().split()] l = N n = max(x,N-x) x = min(x,N-x) while (True): q = n // x r = n % x if r == 0: print(l + (2*q-1)*x) break l += (2*q)*x n = x x = r
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s463592337
p04048
Accepted
N, X = map(int, input().split()) def f(a, b): return 2*a*(b//a) + f(b%a, a) if a else -b print(N + f(N-X, X))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s579936565
p04048
Accepted
n, x = map(int, raw_input().split()) ans = x while 0 < x < n: k = x / (n-x) rest = x % (n-x) ans += 2*k*(n-x) if rest: ans += n-x + rest n, x = n-x, n-x-rest print ans
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s841274627
p04048
Accepted
a,b=map(int,raw_input().split()) t,n,m=a-b,b,a ans=b while 1: if n<m: ans+=t t,n,m=n,t,t elif n%t==0: ans+=n*2-t break else: s=n+m n,m=n%t,m%t+t ans+=s-n-m print ans
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s972682763
p04048
Accepted
N, X = map(int, raw_input().split()) def f(a, b): if a == 0: return -b elif b == 0: return -a elif a < b: return f(a, b % a) + (b / a) * 2 * a else: return f(a % b, b) + (a / b) * 2 * b print N + f(X, N - X)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s400865996
p04048
Accepted
def gcd(a, b): if a > b: tmp = a a = b b = tmp if a == 0: return b else: return gcd(a, b%a) n, x = map(int,input().split()) ans = 3 * (n - gcd(n, x)) print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s301095259
p04048
Accepted
n, x = map(int,input().split()) if x > n // 2: x = n - x xx = x yy = n - x ans = n i = 0 while True: ans += 2 * (yy // xx) * xx yy %= xx if yy == 0: ans -= xx break if yy < xx: tmp = xx xx = yy yy = tmp print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s938140977
p04048
Accepted
n, x = map(int,input().split()) if n % 2 == 0 and n//2 == x: print(3 * x) exit() if x > n // 2: x = n - x xx = x yy = n - x ans = n i = 0 while True: if yy >= xx: ans += 2 * (yy // xx) * xx yy %= xx if yy == 0: ans -= xx break if yy < ...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s083263107
p04048
Accepted
N, X = map(int, input().split()) ans = N N -= X while X > 0: N, X = max(N, X), min(N, X) ans += N // X * X * 2 N, X = X, N % X ans -= N print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s457453370
p04048
Accepted
N, X = map(int, input().split()) Y = N - X ans = N while True: if X == Y: ans += X break else: if X > Y: tmp = X X = Y Y = tmp a = Y % X b = Y // X if a == 0: ans += (b*2 - 1) * X break else: ans += b*2*X Y = X X = a print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s098736322
p04048
Accepted
n, x = map(int, raw_input().split()) s = n r = 1 if n - x > x: a, b = n - x ,x else: a, b = x, n - x while r > 0: q = a / b r = a % b if r > 0: s += 2 * q * b else: s += (2 * q - 1) * b a, b = b, r print s
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s857540639
p04048
Accepted
N,X = map(int,raw_input().split(' ')) l = 0 N, X = max(X,N-X), min(X,N-X) while True: l += (N/X)*X*3 if N%X==0: break N, X = X, N%X print l
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s950565486
p04048
Accepted
n, x = map(int, input().split()) ans, e = n, n-x while x > 0: ans += x * (e//x*2) e, x = x, e%x print(ans-e)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s242890706
p04048
Accepted
def f(a, b): a, b = min(a, b), max(a, b) return (b // a) * 2 * a + (f(a, b % a) if b % a > 0 else -a) n, x = map(int, input().split()) print(f(x, n - x) + n)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s942798286
p04048
Accepted
N, X = map(int,input().split()) ans = N u = N-X d = X while(d!=0): ans += d*(u//d)*2 t = u u = d d = t%d print(ans-u)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s252832086
p04048
Accepted
from fractions import gcd n, k = map(int, input().split(' ')) print(3*(n-gcd(n, k)))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s325456948
p04048
Accepted
def sub(a, b): if (a%b == 0): return a//b-1 return a//b def mod(a, b): if a%b==0: return b return a%b n, x = map(int, input().split(' ')) ans = n c = [x, n-x] while (c[0] != c[1]): c = [min(c), max(c)] ans += 2*sub(c[1], c[0])*c[0] c[1] = mod(c[1], c[0]) print(ans+c[0])
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s976467494
p04048
Accepted
import sys sys.setrecursionlimit(1500) def f(x, y): if x == 0: return 0 if y % x == 0: return 2 * (y // x) * x - x return 2 * (y // x) * x + f(y % x, x) N, X = list(map(int, input().split())) print(f(X, N-X) + N)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s472021971
p04048
Accepted
tmp = [int(x) for x in raw_input().split(' ')] N = tmp[0] X = tmp[1] if(X > 0.5 * N): X = N-X totaldist = N step = X dist = N-X while(1): totaldist += (dist/step) * 2 * step distnew = step stepnew = dist % step if(stepnew == 0): totaldist -= step break dist = distnew step = stepnew print totaldist
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s655089067
p04048
Accepted
args = [ int(x) for x in raw_input().split() ] l0 = args[0] x0 = args[1] def get_length(l, x): if l % x == 0: part = l * 2 - x # print l, x, part return part part = int(l / x) * 2 * x # print l, x, part return part + get_length(x, l % x) length = l0 + get_length(l0 - x0, x0) p...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s936583900
p04048
Accepted
#! /usr/bin/env python3 def f(a, b): if a < b : b, a = a, b c = a // b r = b * 3 * c if a % b > 0 : r += f(b, a-c*b) return r N, X = map(int, input().split()) print(f(X, N-X))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s235812495
p04048
Accepted
n = map(int, raw_input().split()) x = n[1] n = n[0] tpl = x # print '55',tps, tpl if x < float(n)/2: tps = abs(n - 2*x) l = x + n - tps else: l = 0 tps = n - x while tps != 0: # print l # print "t", tps, tpl l += tpl/tps * 3*tps # tpl/tps * 3*tps ntps = tpl % tps tpl = tps tps =...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s831610837
p04048
Accepted
""" def solve(N, X): xmax = ymax = zmax = N xmin = ymin = zmin = 0 org = [N-X, X, 0] pos = [N-X, X, 0] dir = (0, -1, 1) ans = 0 while True: if dir == (0,-1,1): if pos[1]-ymin < zmax-pos[2]: d = pos[1]-ymin pos[1] -= d pos[2] += d dir = (-1,1,0) xmax = pos[0] else: d = zmax-pos[2...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s825221067
p04048
Accepted
N,X = map(int,raw_input().split()) X = min(X,N-X) ans = 0 N -= X while X > 0: ans += N/X * X *3 N,X= X,N%X print ans
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s767993794
p04048
Accepted
#!/usr/bin/env python3 # -*- coding: utf-8 -*- N, X = list(map(int, input().split())) sum_ = X prev = X next = N - X i = 0 while True: num = prev // next if i == 0: sum_ += 2 * num * next elif i % 2 == 1: sum_ += 2 * num * next - next else: sum_ += 2 * num * next - next mod_ ...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s380250602
p04048
Accepted
def calc(N,X): if N%X ==0: return 3*N else: return 3*X*(int(N/X)) + calc(X,N-X*(int(N/X))) N,X = list(map(int, input().split())) X = min(X,N-X) ans = calc(N-X,X) print('%s' % str(ans))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s414580965
p04048
Accepted
n, x = map(int, raw_input().split()) s = 0 t = n - x while t % x != 0: m = t % x s += x * (t / x) t = x x = m s += x * (t / x) print s * 3
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s051327110
p04048
Accepted
n,x=map(int,raw_input().split()) y=n-x ans=x+y if y>=x: while 1: if y%x==0: ans+=x+((y-x)/x)*x*2 print(ans) break else: ans+=((y)/x)*x*2 y,x=x,y%x else: while 1: if x%y==0: ans+=y+((x-y)/y)*y*2 print(ans)...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s757958726
p04048
Accepted
n, x = map(int,raw_input().split()) x = min(n-x,x) ans = 0 def cal(ans,l,s): ans += l/s*s*3 if l%s == 0: return ans else: return cal(ans,max(s,l%s),min(s,l%s)) print cal(ans,n-x,x)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s908649186
p04048
Accepted
n,x=map(int,input().split()) if x>n/2: x = n-x ans = n c = x d = n-x while c > 0: if d%c==0: ans += int(d/c)*(2*c) - c else: ans += int(d/c)*(2*c) c,d = d%c,c print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s384012569
p04048
Accepted
# -*- coding: utf-8 -*- import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll N, X = map(int, raw_input().split()) if X > N/2: alpha = X = N - X ans = N R = N - X while R and X: if R%X == 0: ans += X + 2*(R/X - 1)*X break K = R/X ans += 2*K*X if R == ...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s343031990
p04048
Accepted
from fractions import gcd N, X = map(int, input().split()) print(N * 3 - 3 - (gcd(N, X) - 1) * 3)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s752693961
p04048
Accepted
n,x=map(int, input().split()) total = n h = n-x w = x while h and w: if h == w: total += h h = 0 w = 0 break elif h > w: total += (h//w)*2*w h %= w else: total += (w//h)*2*h w %= h total -= max(w,h) print(total)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s240991215
p04048
Accepted
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import functools def gcd(a, b): while b: a, b = b, a % b return a # @functools.lru_cache(maxsize = None) # def func(N, X): # g = gcd(N, X) # if g == 1: # if X > N // 2: # return func(N, N - X) # if N == 2: # ...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s406843225
p04048
Accepted
def rec(a, b): mx = max(a, b) mn = min(a, b) #print(mn, mx//mn) if mx % mn == 0: return (2 * (mx // mn) - 1) * mn return (2 * mn * (mx // mn)) + rec(mn, mx % mn) N, X = list(map(int, input().split())) #print(N, X) print(rec(N-X, X) + N)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s437804550
p04048
Accepted
if __file__.startswith('/tmp'): import sys; sys.stdin = open('input.txt') n, x = map(int, raw_input().split()) def foo(a, b): if a == b: return a if a > b: return foo(b, a) if a == 0: return -b return 2 * a * (b / a) + foo(b % a, a) print n + foo(x, n - x)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s047819608
p04048
Accepted
N, X = map(int, input().split()) def solve(a, b): d = a // b m = a % b if m==0: return (d * 2 - 1) * b else: return d * 2 * b + solve(b, m) print(N + solve(X, N-X))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s888053853
p04048
Accepted
#!/usr/bin/env python3 def f(n, x): if n % x == 0: return (n // x * 2 - 1) * x else: return (n // x * 2) * x + f(x, n % x) n, x = map(int,input().split()) ans = n + f(n - x, x) print(ans)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s609499278
p04048
Accepted
from fractions import gcd n, x = map(int, raw_input().split()) g = gcd(n, x) n /= g x /= g print 3 * (n - 1) * g
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s960577688
p04048
Accepted
N,X=map(int,input().split()) A=N X,N = sorted((X,N-X)) while N != X and X != 0: if N%X == 0: A += 2*(N//X-1)*X X,N=X,X else: A += 2*(N//X)*X X,N=sorted((X,N%X)) print(A+X)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s998319904
p04048
Accepted
n, x = map(int, raw_input().split()) def solve(a, b): if a > b:return solve(b, a) if b % a == 0: return (2 * (b / a) - 1) * a return 2 * a * (b / a) + solve(a, b % a) print solve(x, n-x) + n
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s555175969
p04048
Runtime Error
n = int(input()) a = sorted(map(int, input().split())) s = 0 for i in range(2*n-1): s += min(a[i], a[i+1]) print(s)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s313668169
p04048
Runtime Error
import sympy n,x = map(int,input().split()) print(n-x+sum(sympy.divisors(x))*3)
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s297220978
p04048
Runtime Error
import math n, x = map(int, input().split()) print(3 * (n - gcd(n, x)))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s361058051
p04048
Runtime Error
def milor(a,b): if a == b: return a if a > b: a,b = b,a return milor(b-a,a) + 2*a def solve(n,x): res = n + milor(x,n-x) return res if __name__ == '__main__': n,x = map(int,input().split()) print(solve(n,x))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s311100241
p04048
Runtime Error
N,X = input().split() N,X = int(N), int(X) answer = X+ (N-X) def rhombus(N,X): if N<X: temp = N N = X X = temp if X==1: return N+1 if X==0: return 0 if N%X == 0: return X*(N//X)*2-X else: k = N//X return k*2*X + rho...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s264994960
p04048
Runtime Error
n,x=map(int,input().split()) k=(x/(n-2*x))*(n-2*x) ans=2*x+n+k print(int(ans+1))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s634847381
p04048
Runtime Error
from collections import deque from heapq import heapify,heappop,heappush,heappushpop from copy import copy,deepcopy from itertools import permutations,combinations from collections import defaultdict,Counter from math import gcd # from fractions import gcd from functools import reduce from pprint import pprint def myi...
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...
s365925693
p04048
Runtime Error
def move(mode, N, X, total): tmp = total if mode == 0: tmp += (N-X) return move(1, N-X, X, tmp) if mode == 1: tmp += X next = 0 if N-X == 0: return tmp return move(next, N, N-X, tmp) N, X = map(int, input().split(" ")) print(move(0, N, X, X))
5 2
12
<span class="lang-en"> <p>Score : <var>500</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p> <p>Three mirrors of length <var>N</var> are set so that they form an equilatera...