submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s030726620
p04048
Accepted
#B n,x = [int(i) for i in input().split()] ans = x a = x p = n-x while(1): q,r = divmod(a,p) ans += p * 2* q if r==0: print(ans) break else: ans += p ans += r a = p -r p = 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...
s337939583
p04048
Accepted
import fractions N,X=map(int,input().split()) print(int(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...
s059552557
p04048
Accepted
# --*-coding:utf-8-*-- N, X = map(int, input().split()) S = N a = N - X b = X while b > 0: c = a%b S += 2*(a-c) a,b = b,c 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...
s935131823
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...
s566697952
p04048
Accepted
import sys input = sys.stdin.readline sys.setrecursionlimit(1000000) from collections import deque, Counter def getN(): return int(input()) def getList(): return list(map(int, input().split())) import math INF = 10**10 def bfs(graph, visited, position, root): visited[root] = 1 position[root] = 0 deq...
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...
s068524854
p04048
Accepted
N, X = map(int, input().split()) 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...
s156187298
p04048
Accepted
n, x = map(int, input().split()) ans = n y, x = n-x, x if x > y: y, x = x, y while True: q, r = divmod(y, x) if r == 0: ans += (2*q-1)*x break ans += 2*q*x y, x = x, r 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...
s357671186
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...
s664228161
p04048
Accepted
n,x = map(int,input().split()) ans = n A = x B = n-x while A and B: if A<B: A,B = B,A k = A//B if A%B: ans += k*B*2 else: ans += B*(k*2-1) A = A%B 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...
s927215127
p04048
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,X = map(int,read().split()) def F(A,B): # (A,B)の平行四辺形の120度の対角から出た状態 if A > B: A,B = B,A q,r = divmod(B,A) if not r: return A * (q+q-1) return F(A,r) + q * (2 * 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...
s021348992
p04048
Accepted
def run(): N, X = map(int, input().split()) y = N-X ans = N while True: y, X = max(y, X), min(y, X) a = y//X b = y%X ans += a*X*2 if b == 0: break y, X = X, b print(ans-X) if __name__ == '__main__': run()
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...
s432672785
p04048
Accepted
def main(): n, x = map(int, input().split()) ans = n a, b = min(x, n-x), max(x, n-x) while a > 0: ans += 2*(b//a)*a a, b = b % a, a print(ans-b) main()
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...
s584383797
p04048
Accepted
n,x = [int(i) for i in input().split()] length = n n=n-x while True: t=n//x length+=2*t*x a=n n=x x=a-t*x if x==0: length-=n break print(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...
s831954461
p04048
Accepted
#!/usr/bin/env python3 import sys from math import sqrt def solve(N: int, X: int): # 平行四辺形の面積 answer = N a,b = max(N-X,X),min(N-X,X) while True: answer += 2*(a//b)*b if a%b == 0: answer -= b break a,b = b,a%b print(answer) return def main(): ...
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...
s385915610
p04048
Accepted
import sys N,X = map(int,input().split()) ans = 0 oldx = 0 if N > 2 * X: ans = N N = N - X elif N == 2 * X: ans = 3 * X print (ans) sys.exit() else: ans = N oldx = X X = N - X N = oldx while True: #print (N,X,ans) if N % X == 0: ans += ((N // X) * 2 - 1) * 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...
s183083130
p04048
Accepted
N, X = map(int, input().split()) ans = N a, b = max(X, N-X), min(X, N-X) while b: q, r = divmod(a, b) if r == 0: ans += b * (2 * q - 1) else: ans += b * 2 * q a, b = max(b, r), min(b, r) 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...
s375248954
p04048
Accepted
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits fro...
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...
s924381346
p04048
Accepted
N, X = map(int, raw_input().strip().split()) ans = N a, b = N-X, X if b > a: a, b = b, a while b > 0: k = 2 * (a / b) if a % b == 0: k -= 1 ans += k * b a, b = b, a % b 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...
s819723548
p04048
Accepted
N, X = map(int, input().split()) def solve(edge, width, ans): a, b = divmod(width, edge) if b == 0: return ans+edge*(2*a-1) return solve(width-edge*a, edge, ans + edge*2*a) print(solve(min(X,N-X), max(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...
s755419303
p04048
Accepted
from fractions import* 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...
s711075829
p04048
Accepted
import sys import fractions from collections import Counter, deque, defaultdict from math import factorial import heapq, bisect import math import itertools sys.setrecursionlimit(10 ** 5 + 10) INF = 10**15 +5 def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, inpu...
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...
s824511282
p04048
Accepted
n, x = map(int, input().split()) ans = 0 def rec(a,b): global ans if a > b: a,b = b,a if b%a == 0: k = b//a ans += (2*k-1)*a else: k = b//a ans += 2*k*a rec(a, b%a) ans += n rec(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...
s052510646
p04048
Accepted
import sys sys.setrecursionlimit(10000000) def input(): return sys.stdin.readline()[:-1] from bisect import * from collections import * from heapq import * import itertools INF = 10**10 MOD = 10**9+7 N, X = map(int, input().split()) a, b, ans = max(X, N-X), min(X, N-X), N while 1: ans += 2*b*(a//b) 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...
s841063452
p04048
Accepted
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(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...
s247693168
p04048
Accepted
def gcd(a,b): while b:a,b=b,a%b return a n,x=map(int,input().split());print((n-gcd(n,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...
s415504689
p04048
Accepted
def gcd(a,b): while b:a,b=b,a%b return a n,x=map(int,input().split());print((n-gcd(n,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...
s311931212
p04048
Accepted
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(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...
s139965746
p04048
Accepted
n, x = map(int, input().split()) ans = n wall_side = n - x light_length = n - (n - x) while True: if wall_side % light_length == 0: ans += (2 * (wall_side // light_length - 1) + 1) * light_length break else: ans += 2 * (wall_side // light_length) * light_length wall_side, light...
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...
s506231618
p04048
Accepted
# -*- coding: utf-8 -*- import sys if sys.version_info.minor >= 5: from math import gcd else: from fractions import gcd def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(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...
s504779492
p04048
Accepted
n, x = map(int, input().split()) a, b = max(n-x,x),min(n-x,x) res = a+b while b!=0: q = a//b r = a%b res += (b*2)*q if (r==0): res -= b a, b = b, r 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...
s779236580
p04048
Accepted
import sys input = sys.stdin.readline def main(): N, X = map(int, input().split()) ans = N min_ = min(X, N-X) max_ = max(X, N-X) while min_ != 0: # print(max_, min_) ans += (max_ // min_) * 2 * min_ tmp = max_ % min_ max_ = min_ min_ = tmp ans -= max_ ...
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...
s860314589
p04048
Accepted
N, X = map(int, input().split()) q, p = sorted((N - X, X)) r = 1 while r: p, r = divmod(p, q) N += (2 * p - (r == 0)) * q p, q = q, r print(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...
s683154326
p04048
Accepted
N,X=map(int,input().split()) ans=0 a,b=max(N-X,X),min(N-X,X) r=1 while r: r=a%b ans+=3*b*(a//b) a,b=b,r 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...
s288208467
p04048
Accepted
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) N,X = map(int,input().split()) def F(x,y): """ x,yの平行四辺形。対角にたどり着くまでの距離 """ if x>y: x,y = y,x q,r = divmod(y,x) if r == 0: return (2*q-1)*x return 2*q*x + F(x,y%x) answer = N + F(X,N-X) print(answer)
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...
s804693083
p04048
Accepted
import sys import heapq from operator import itemgetter from collections import deque, defaultdict from bisect import bisect_left, bisect_right input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) MOD = 10**9 + 7 def sol(): N, X = map(int, input().split()) ans = N A = max(N - X, X) B = min(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...
s134463842
p04048
Accepted
n,x=map(int,input().split()) ans=n M=max(n-x,x) m=min(n-x,x) while(True): r=M%m q=int((M-r)/m) if(r==0): ans+=(2*q-1)*m break else: ans+=2*q*m M=m m=r 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...
s473109116
p04048
Accepted
from fractions import*;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...
s733850664
p04048
Accepted
a,x=map(int,input().split()) q,p=sorted((a-x,x)) while q: a+=(p//q*2-(p%q<1))*q p,q=q,p%q print(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...
s516282759
p04048
Accepted
a,x = map(int,input().split()) q,p = sorted((a-x,x)) r = 1 while r: p,r = divmod(p,q) a += (2*p-(r==0))*q p,q = q,r print(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...
s413387511
p04048
Accepted
n,x=[int(i) for i in input().split()] ans=n a,b=min(x,n-x),max(x,n-x) while a: c=b%a ans+=(b-c)*2 a,b=c,a ans-=b 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...
s129631581
p04048
Accepted
N,X = map(int,input().split()) ans = N x=X y=N-X if x<y:x,y=y,x while y!=0: k = x//y ans += y*k*2 x,y = y,x%y ans -= 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...
s978395756
p04048
Accepted
n,x=map(int,input().split()) c=n def sol(a,b): global c if a==b:c+=a elif a%b==0:c+=b*(2*(a//b)-1) elif b%a==0:c+=a*(2*(b//a)-1) elif a>b: c+=b*(a//b)*2 sol(a-a//b*b,b) else: c+=a*(b//a)*2 sol(a,b-b//a*a) sol(x,n-x) print(c)
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...
s900302027
p04048
Accepted
N, X = map(int, input().split()) ans = N a = N - X b = X while a != b: if a >= b: a, b = b, a if b%a != 0: ans += 2 * a * (b//a) b = b%a else: ans += 2 * a * (b//a - 1) b = a 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...
s509274593
p04048
Accepted
n,x = map(int,input().split()) import math def f(x,y): a = min(x,y) b = max(x,y) if a == 0: return 0 elif b%a == 0: return 2*b-a else: return 2*a*math.floor(b/a) + f(a,b%a) 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...
s915113440
p04048
Accepted
def gcd(a, b): while b: a, b = b, a % b return a def main(): hen, start=map(int,input().split()) koyakusuu = gcd(hen, start) ans = koyakusuu * 3 * (hen // koyakusuu - 1) print(ans) if __name__ == '__main__': main()
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...
s554996164
p04048
Accepted
N, X = map(int, input().split()) # 横に2個 X = X if 2*X <= N else N - X a = X b = (N-X)//X c = (N-X)%X ans = 0 while True: ans += a*b*3 if c == 0: break a, b, c = c, a//c, a%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...
s794365330
p04048
Accepted
def trapizoid_light(side, bottom): if (bottom - side) % side == 0: return 2 * (bottom - side) next_side = bottom % side return 2 * ((bottom - side) // side * side) + side + next_side + trapizoid_light(next_side, side) N, X = map(int, input().split()) if N % 2 == 0 and N // 2 == X: print(3 * 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...
s349108191
p04048
Accepted
N,X=map(int,input().split()) def gcd(a,b): while a%b>0: a,b=b,a%b return b g=gcd(N,X) ans=g*3*(N//g-1) 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...
s154517879
p04048
Accepted
def main(): n, x = map(int, input().split()) remainder = n - (2 * x) if remainder == 0: print(3 * x) return if remainder < 0: n, x = x, (n - x) else: n -= x ans = 0 while True: num = n // x ans += (3 * x) * num rem = n % x i...
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...
s451595171
p04048
Accepted
def gcd(a: int, b: int)->int: if a < b: a, b = b, a return a if b == 0 else gcd(b, a % b) def mysterious_light(N: int, X: int)->int: g = gcd(N, X) return 3 * max(N-g, g) if __name__ == "__main__": N, X = map(int, input().split()) ans = mysterious_light(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...
s805954247
p04048
Accepted
N,X = map(int,input().split()) x = X y = N-X if x<y: x,y = y,x res = N while y>0: x,y = y,x m = x*(y//x) res += m*2 y -= m res -= 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...
s362373879
p04048
Accepted
N,X = map(int,input().split(" ")) Y,X = sorted([N - X,X]) s = 0 while Y: s += (X//Y)*Y*3 Y,X = [X%Y,Y] 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...
s789912000
p04048
Accepted
def calc(a,b,ans): if b==0: return ans else: return calc(b,a%b,ans+b*(a//b)*3) n,x=map(int,input().split()) n=n-x n,x=max(n,x),min(n,x) print(calc(n,x,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...
s874701479
p04048
Accepted
N,X = map(int,input().split(" ")) Y,X = sorted([N - X,X]) s = 0 while Y: s += (X//Y)*Y*3 Y,X = [X%Y,Y] 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...
s877696083
p04048
Accepted
N,X = map(int, input().split()) if N/2 == X: l = X*3 elif N/2 > X: l = N x = X n = N - X while x > 0: l += (n//x)*2*x c = x x = n%x n = c l -= n else: l = N x = X n = N - X while x > 0: l += (n//x)*2*x c = x 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...
s068437222
p04048
Accepted
n, x = [int(i) for i in input().split()] cnt=0 short = min(x,n-x) long = max(x, n-x) cnt += n #cnt += x*(2*(n//x)-1) + (n-x) while(1): c = long % short a = long //short if c==0: break else: cnt += short * 2 * a long = short short = c cnt += short * (2 * a -1) print(c...
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...
s217425975
p04048
Accepted
def f(a,b): if a==b: d=0 ret = a elif a < b: d = b//a if b%a == 0: ret = a*(2*d -1) else: ret = 2*a*d + f(a,b%a) else: d = a//b if a%b == 0: ret = b*(2*d -1) else: ret = 2*b*d + f(a%b,b) #print(a,b,d,ret) return ret N,X = map(int,input().split(" ")) 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...
s720742160
p04048
Accepted
"""B - Mysterious Light""" N,X=(int(i) for i in input().split()) def MysteriousLight(tmp,rem): while rem: tmp, rem= rem,tmp%rem return tmp print(3*(N-MysteriousLight(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...
s578241618
p04048
Accepted
N, X = list(map(int, input().split())) ans = N a, b = sorted([X, N - X]) while True: if b % a == 0: ans += (int(b / a) * 2 - 1) * a break else: ans += int(b // a) * a * 2 a, b = b % 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...
s312454322
p04048
Accepted
# -*- coding: utf-8 -*- def rli(): return list(map(int, input().split())) def solve(n, x): if x < n - x: x = n - x w = n - x t = (w - (x % w)) % w res = (x + w - 1) // w * 3 * w - t * 3 if t != 0: res += solve(w, w - t) return res def main(): n, x = rli() print(...
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...
s269810115
p04048
Accepted
n, x = map(int, input().split()) total = n a = x b = n - x while a > 0: total += (a * 2) * (b // a) a, b = b % a, a print(total - 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...
s583034545
p04048
Accepted
N,x=map(int,input().split()) x=min(x,N-x) rem=[N-x,x] len=x ans=N i=1 while True: i=(i+1)%2 ans+=2*(rem[i]//len)*len rem[i]=rem[i]%len if rem[i]!=0: len=rem[i] else: break print(ans-len)
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...
s143554382
p04048
Accepted
N,X=map(int,input().split()) def f(a,b): if a>b: return f(b,a) if b%a==0: return a*(2*(b//a) - 1) return 2*(b//a)*a + f(b%a,a) 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...
s558246325
p04048
Accepted
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nn = lambda: list(stdin.readline().split()) ns = lambda: stdin.readline().rstrip() n,x = na() def loop(a,b): h = max(a,b) w = min(a,b) if h%w == 0: return int((2*h/w-1)*w) else: 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...
s140575390
p04048
Accepted
def f(a,b): a,b=min(a,b),max(a,b) if b%a==0: return (2*b//a-1)*a else: return 2*a*(b//a)+f(a,b%a) n,x=map(int,input().split()) 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...
s861375142
p04048
Accepted
#!usr/bin/env python3 from collections import defaultdict from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, sys.stdin.readline().split())) def 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...
s380813222
p04048
Accepted
n, x = map(int, input().split()) p = n if x * 2 > n: x = n - x ans = 0 while(x > 0): if n == p: ans += 3 * x * (n // x - 1) else: ans += 3 * x * (n // x) 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...
s101809950
p04048
Accepted
n,x = map(int,input().split()) def gcd(a,b): if a%b == 0: return b else: return gcd(b,a%b) k = gcd(n,x) if k == 1: print((n-1)*3) else: print((int(n/k)-1)*3*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...
s037011222
p04048
Accepted
def main(): n,x=map(int,input().split()) a,b=n-x,x if(a<b): a,b=b,a path_length = calc_path(a,b,n) print(path_length) def calc_path(a1,b1,c1): q , mod=divmod(a1,b1) count=0 if mod==0: c2=c1+2*b1*q-b1 return c2 else: count=count+1 c2=c1+2*b1*...
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...
s552887138
p04048
Accepted
def gcd(x,y): if(x < y): x,y = y,x if(y == 0): return x return gcd(y,x % y) n,x = map(int,input().split()) g = gcd(n,x) n //= g print((3*n-3)*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...
s994394061
p04048
Accepted
# coding:utf-8 import sys INF = float('inf') 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 LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def II():...
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...
s525625050
p04048
Accepted
import sys sys.setrecursionlimit(10 ** 9) N, X = map(int, input().split()) def rec(a, b): a, b = min(a, b), max(a, b) if b % a == 0: return (2 * a) * (b // a) - a else: return (2 * a) * (b // a) + rec(a, b % a) print(X + N - X + rec(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...
s588314224
p04048
Accepted
n,x = map(int,input().split()) x = min(x,n-x) n = n - x ans = 0 while True: new_x = n%x new_n = n//x if new_x ==0: print(ans+x*new_n*3) exit() else: ans = ans + x*new_n*3 n = x x = new_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...
s503683315
p04048
Accepted
def solve(s, a, b): if a % b == 0: return s + ((a // b) * 2 - 1) * b if b % a == 0: return s + ((b // a) * 2 - 1) * a elif a > b: s += (a // b) * 2 * b return solve(s, a % b, b) else: s += (b // a) * 2 * a return solve(s, a, b % a) n, x = map(int, input()...
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...
s963121308
p04048
Accepted
n, x = map(int, input().split()) def g(a, b): if a%b == 0:return b return g(b, a%b) ans = 3*(n-g(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...
s338757392
p04048
Accepted
def gcd(a, b): if b == 0: return a 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...
s522572407
p04048
Accepted
n, x = map(int, input().split()) if (x > n // 2 and n % 2 == 0) or (x > (n + 1) // 2 and n % 2 == 1): x = n - x A = n - x B = x k = 0 m = -1 ans = n while m != 0: k = A // B m = A % B ans += B * k * 2 if m == 0: ans -= B A = B B = 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...
s249034321
p04048
Accepted
import sys sys.setrecursionlimit(100000) from math import floor n,x=map(int,input().split()) ans=0 def f(x,y): if y%x==0: return (y//x-1)*2*x+x return 2*x*(y//x)+f(y%x,x) print(n+f(min(x,n-x),max(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...
s876361459
p04048
Accepted
import fractions n,x = (int(i) for i in input().split()) ans = fractions.gcd(n,x) 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...
s381260099
p04048
Accepted
N, X = map(int, input().split()) l = 0 if X < N-X: long = N - X short = X else: long = X short = N - X l += N while True: l += long // short * short * 2 x = long % short if x == 0: l -= short break long = short short = 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...
s156822289
p04048
Accepted
def gcd(a, b): while b: a, b = b, a % b return a li = [int(i) for i in input().split(" ")] res = (li[0] // gcd(li[0], li[1]) -1) * 3 * gcd(li[0], li[1]) 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...
s950561751
p04048
Accepted
N, X = map( int, input().split()) a, b = max(X, N-X), min(X, N-X) #a >= b ans = a + b if a == b: ans += a while a != b: if a%b == 0: ans += (a//b*2-1)*b break ans += a//b*2*b a, b = b, a%b 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...
s410601602
p04048
Accepted
n, x = map(int, input().split()) # a <= b def f(a, b): if b % a == 0: return (b // a) * 2 * a - a return (b // a) * a * 2 + f(b % a, a) print(n + f(min(x, n - x), max(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...
s598988198
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...
s783693060
p04048
Accepted
N,X = map(int,input().split()) def f(a,b) : if a > b : a,b = b,a if b % a == 0 : return 2*(b//a-1)*a + a else : return 2*(b//a)*a + f(a,b%a) ans = N + f(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...
s194143299
p04048
Accepted
import sys stdin = sys.stdin sys.setrecursionlimit(10**8) 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(...
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...
s917308530
p04048
Accepted
N,X = map(int,input().split()) ans = N a,b = X,N-X if a>b: a,b = b,a while a: d,m = divmod(b,a) ans += d*a*2 a,b = m,a if a>b: a,b = b,a ans -= b 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...
s038072391
p04048
Accepted
# your code goes here from math import floor N, X = [int(x) for x in input().split()] y = N-X x = X L = X while x > 0: # k = 2*floor(y/x) k, z = divmod(y, x) # dL = x*(2*k-1)+y L += x*(2*k-1)+y # print(x, y, k, dL) y, x = (x, z) #L += y 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...
s825981109
p04048
Accepted
import sys sys.setrecursionlimit(10**7) def f(a,b): if a==b:return a if not a<b:a,b=b,a return 2*(b//a)*a+f(a,b%a) if b%a else 2*(b//a)*a-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...
s590590950
p04048
Accepted
N, X = map(int, input().split()) TotalLength = N Vert = N-X Hor = X Fin = False while not Fin: if Vert < Hor: if Hor % Vert == 0: TotalLength += (2 * (Hor//Vert) - 1) * Vert Fin = True else: TotalLength += 2 * (Hor//Vert) * Vert Hor %= Vert else: ...
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...
s425456402
p04048
Accepted
n, a = map(int, input().split(' ')) b = n - a if a < b: a, b = b, a ans = n while b: q = a // b ans += 2 * q * b a %= b a, b = b, a 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...
s270601312
p04048
Accepted
# %%time import numpy as np n, x = list(map(int, input().split())) s = 0 a = [n-x, x] s += n # print(a,s) while True: # if a[0] == a[1]: # s += a[0] # break # else: mi = np.min(a) ar = np.argmax(a) num = a[ar]//mi a[ar] -= mi * num s += 2 * mi * num # print(a, s) if 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...
s573567027
p04048
Accepted
def f(a, b): if a > b: a, b = b, a if a == 0: return -b return 2*(b/a)*a + f(a, b%a) n, x = map(int, raw_input().split()) 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...
s957027440
p04048
Accepted
#最大公約数 def gcd(a,b): if a==b: return b elif a%b== 0: return b else: return gcd(b,a%b) import math def func(a,b): if a<=b : if b%a != 0: return 2*math.floor(b/a)*a+func(a,b%a) else: return 2*(math.floor(b/a))*a-a else: return f...
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...
s106590695
p04048
Accepted
n,x = map(int,input().split()) ans = 0 if 2*x == n: ans = 3*x else: ans += n a = x b = n - x while True: ans += (a//b)*2*b c = b b = a%b a = c if b == 0: ans -= a break 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...
s916453423
p04048
Accepted
n,x = map(int,input().split()) ans = 0 if 2*x == n: ans = 3*x else: ans += n a = x b = n - x while True: ans += (a//b)*2*b c = b b = a%b a = c if b == 0: ans -= a break 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...
s049975237
p04048
Accepted
N,X = map(int,input().split()) ans = N a,b = X, N-X if a > b: a,b = b,a while b: d,m = divmod(a,b) ans += 2*b*d a,b = b,m 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...
s875310760
p04048
Accepted
N, X = map(int, input().split()) ans = N a, b = sorted((X, N - X)) while a != 0: if b % a == 0: ans += 2 * (b // a - 1) * a + a print(ans) break else: ans += 2 * (b // a) * a a, b = sorted((a, 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...
s574531356
p04048
Accepted
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...
s945542266
p04048
Accepted
N, X = map(int, input().split()) ans = N a, b = sorted((X, N - X)) while a != 0: if b % a == 0: ans += 2 * (b // a - 1) * a break else: ans += 2 * (b // a) * a a, b = sorted((a, b % a)) 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...