s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
int64
0
100
memory
stringlengths
4
6
code_size
int64
15
14.7k
code
stringlengths
15
14.7k
problem_id
stringlengths
6
6
problem_description
stringlengths
358
9.83k
input
stringlengths
2
4.87k
output
stringclasses
807 values
__index_level_0__
int64
1.1k
1.22M
s165889913
p04047
u374099594
1468717395
Python
Python (2.7.6)
py
Accepted
28
2568
62
input() print sum(sorted(map(int, raw_input().split()))[::2])
p04047
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having a barbeque party.</p> <p>At the party, he will make <var>N</var> servings of <em>Skewer Meal</em>.</p> <div style="text-align: center;"> <img src="https://agc001.contest.atcoder.jp/img/a...
2 1 3 1 2
3
1,217,517
s585199164
p04047
u207056619
1468717384
Python
Python (3.4.3)
py
Accepted
40
3064
236
#!/usr/bin/env python3 def f(xs, ys): acc = 0 for x, y in zip(xs, ys): acc += min(x, y) return acc n = int(input()) l = sorted(map(int,input().split())) ans = max(f(l[0::2], l[1::2]), f(l[1::2], l[2::2])) print(ans)
p04047
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having a barbeque party.</p> <p>At the party, he will make <var>N</var> servings of <em>Skewer Meal</em>.</p> <div style="text-align: center;"> <img src="https://agc001.contest.atcoder.jp/img/a...
2 1 3 1 2
3
1,217,518
s691098616
p04047
u022488946
1468717364
Python
PyPy2 (5.6.0)
py
Accepted
67
8816
67
raw_input() print sum(sorted(map(int, raw_input().split()))[0::2])
p04047
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having a barbeque party.</p> <p>At the party, he will make <var>N</var> servings of <em>Skewer Meal</em>.</p> <div style="text-align: center;"> <img src="https://agc001.contest.atcoder.jp/img/a...
2 1 3 1 2
3
1,217,519
s681737071
p04047
u357487020
1468717363
Python
Python (2.7.6)
py
Accepted
29
2568
102
n=input() l=map(int,raw_input().split()) l.sort() cnt=0 for i in xrange(n): cnt+=l[i*2] print(cnt)
p04047
<span class="lang-en"> <p>Score : <var>200</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having a barbeque party.</p> <p>At the party, he will make <var>N</var> servings of <em>Skewer Meal</em>.</p> <div style="text-align: center;"> <img src="https://agc001.contest.atcoder.jp/img/a...
2 1 3 1 2
3
1,217,520
s489006563
p04048
u821322673
1600829532
Python
PyPy3 (7.3.0)
py
Accepted
63
61884
182
n, x = map(int, input().split()) a = max(n-x, x); b = min(n-x, x) res = n while b!=0: p=a; q=int(a/b); r=a%b res+=q*(2*b) if r==0: res-=b a=b; b=r print(res)
p04048
<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...
5 2
12
1,217,521
s375714517
p04048
u023229441
1599604570
Python
Python (3.8.2)
py
Accepted
27
9140
150
n,x=map(int,input().split()) def f(a,b): if a>b: b,a=a,b if b%a==0: return (2*(b//a)-1)*a return 2*a*(b//a)+ f(b%a,a) print(n+ f(x,n-x))
p04048
<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...
5 2
12
1,217,522
s096161027
p04048
u456353530
1599492084
Python
PyPy3 (7.3.0)
py
Accepted
60
61972
356
N, X = list(map(int, input().split())) ans = N N, X = X, N - X while N and X: if X > N: d, m = divmod(X, N) if m == 0: ans += (d * 2 - 1) * N else: ans += d * 2 * N N, X = N, m else: d, m = divmod(N, X) if m == 0: ans += (d * 2 - 1) * X else: ans += d * 2 * X + m...
p04048
<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...
5 2
12
1,217,523
s109261748
p04048
u697658632
1598423663
Python
Python (3.8.2)
py
Accepted
27
9064
77
import math n, x = map(int, input().split()) print(3 * (n - math.gcd(n, x)))
p04048
<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...
5 2
12
1,217,524
s276715694
p04048
u780962115
1597777214
Python
PyPy3 (7.3.0)
py
Accepted
66
61884
231
N, X = map(int, input().split()) def func(X, Y): if X < Y: return func(Y, X) # X>=Y if X % Y == 0: return 2*X-Y else: return 2*Y*(X//Y) + func(Y, X % Y) ans = N + func(X, N-X) print(ans)
p04048
<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...
5 2
12
1,217,525
s073001618
p04048
u368796742
1597771334
Python
Python (3.8.2)
py
Accepted
26
9172
175
n,x = map(int,input().split()) ans = n e = n-x while e > 0: if x%e == 0: ans += x//e*(e*2)-e else: ans += (x//e)*e*2 x,e = e,x%e print(ans)
p04048
<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...
5 2
12
1,217,526
s052772062
p04048
u368796742
1597771120
Python
Python (3.8.2)
py
Accepted
34
9108
220
n,x = map(int,input().split()) ans = n e = n-x count = 0 while True: if x%e == 0: ans += x//e*(e*2)-e break else: ans += (x//e)*e*2 x,e = e,x%e count += 1 print(ans)
p04048
<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...
5 2
12
1,217,527
s001893091
p04048
u653837719
1597511279
Python
Python (3.8.2)
py
Accepted
28
9124
182
n, x = map(int, input().split()) def func(a, b): if b == 0: return -a else: return 2 * (a // b) * b + func(b, a%b) print(n + func(max(n-x, x), min(n-x, x)))
p04048
<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...
5 2
12
1,217,528
s245813452
p04048
u653837719
1597511070
Python
Python (3.8.2)
py
Accepted
26
9128
243
n, x = map(int, input().split()) def func(a, b): if a < b: a, b = b, a res = 0 while b > 0: c, d = divmod(a, b) res += 2 * b * c a = b b = d return res - a print(n + func(x, n-x))
p04048
<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...
5 2
12
1,217,529
s981932092
p04048
u653837719
1597510512
Python
Python (3.8.2)
py
Accepted
28
9128
208
n, x = map(int, input().split()) def func(a, b): res = 0 while b > 0: c, d = divmod(a, b) res += 2 * b * c a = b b = d return res - a print(n + func(x, n-x))
p04048
<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...
5 2
12
1,217,530
s411200306
p04048
u653837719
1597510340
Python
Python (3.8.2)
py
Accepted
28
9096
324
n, x = map(int, input().split()) def func(a, b): res = 0 while b > 0: c, d = divmod(a, b) res += 2 * b * c a = b b = d return res - a if n == 2 * x: print(3 * x) elif n > 2 * x: print(n + 2 * x + func(max(x, n-2*x), min(x, n-2*x))) else: print(n + func(x, n...
p04048
<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...
5 2
12
1,217,531
s543440589
p04048
u587589241
1597015066
Python
PyPy3 (7.3.0)
py
Accepted
63
62080
70
from math import * n,x=map(int,input().split()) print(3*(n-gcd(n,x)))
p04048
<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...
5 2
12
1,217,532
s760064126
p04048
u126146165
1596843223
Python
Python (3.8.2)
py
Accepted
29
9104
81
import math n,x = map(int, input().split()) t = math.gcd(n,x) print(3*(n//t-1)*t)
p04048
<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...
5 2
12
1,217,533
s314848377
p04048
u489959379
1596728066
Python
Python (3.8.2)
py
Accepted
29
9036
343
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n, x = map(int, input().split()) n -= x res = 0 while x != 0: q, r = divmod(n, x) res += q * x * 3 n = x x = r print(res) if __name__ == '__...
p04048
<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...
5 2
12
1,217,534
s943853722
p04048
u761154175
1596588062
Python
PyPy3 (7.3.0)
py
Accepted
63
61848
215
def gcd(a,b): if b == 0: return a return gcd(b,a%b) def solve(n,x): res = 3 * (n - gcd(n,x)) return res if __name__ == '__main__': n,x = map(int,input().split()) print(solve(n,x))
p04048
<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...
5 2
12
1,217,535
s219539227
p04048
u883621917
1596338550
Python
PyPy3 (7.3.0)
py
Accepted
76
61960
673
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) n, x = map(int, input().split()) ans = 0 ans += n l1, l2 = min(n - x, x), max(n - x, x) #while True: # if l1 == l2: # ans += l1 # break # else: # ans += (l1 * 2) # l1, l2 = min(l1, l2 -l1), max(l1, l2 - l1) #while ...
p04048
<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...
5 2
12
1,217,536
s867386075
p04048
u644972721
1596260849
Python
Python (3.8.2)
py
Accepted
31
9136
77
import math n, x = map(int, input().split()) print(3 * (n - math.gcd(n, x)))
p04048
<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...
5 2
12
1,217,537
s873681630
p04048
u139112865
1595484667
Python
Python (3.8.2)
py
Accepted
31
9076
260
n, x = map(int, input().split()) def f(a, b): if a == b: return a if a > b: a, b = b, a if b % a == 0: return 2 * b - a else: div, mod = divmod(b, a) return 2 * a * div + f(a, mod) print(n + f(n-x, x))
p04048
<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...
5 2
12
1,217,538
s152005424
p04048
u923270446
1595186859
Python
Python (3.8.2)
py
Accepted
24
9156
67
import math n,x=map(int,input().split()) print(3*(n-math.gcd(n,x)))
p04048
<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...
5 2
12
1,217,539
s028636405
p04048
u535803878
1593661523
Python
PyPy3 (7.3.0)
py
Accepted
70
61780
458
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,x = map(int, input().split()) v0 = n v1 = n-x ans = x init = 0 while True: num, amari = divmod(v0,v1) # print(ans, v0,v1) if amari==0: ans += (2*(num-1)+in...
p04048
<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...
5 2
12
1,217,540
s783730913
p04048
u923270446
1593561924
Python
Python (3.8.2)
py
Accepted
25
9172
67
import math n,x=map(int,input().split()) print(3*(n-math.gcd(n,x)))
p04048
<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...
5 2
12
1,217,541
s157369906
p04048
u081661483
1592772020
Python
Python (3.8.2)
py
Accepted
26
9180
239
N, X = [int(x) for x in input().split()] def solution(N, X): if N<X: N, X = X, N if not N % X: return (2*(N//X) -1) * X else: return 2*(N//X)*X + solution(X, N%X) answer = solution(N-X, X) + N print(answer)
p04048
<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...
5 2
12
1,217,542
s323769427
p04048
u856671164
1592768928
Python
Python (3.8.2)
py
Accepted
28
9140
328
N,X = input().split() N,X = int(N), int(X) answer = X+ (N-X) def rhombus(N,X): if X==1: return N*2-1 if X==0: return 0 if N%X == 0: return X*(N//X)*2-X else: k = N//X return k*2*X + rhombus(X,N-(k*X)) answer = answer + rhombus(N-X,X) print...
p04048
<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...
5 2
12
1,217,543
s690311569
p04048
u102461423
1592590080
Python
Python (3.8.2)
py
Accepted
26
9036
345
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def f(a, b): if a == 0 or b == 0: return 0 if a > b: q, r = divmod(a, b) return 2*q*b + f(a % b, b) else: return a+b+f(b-a, a) N, X = map(int, read().split()...
p04048
<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...
5 2
12
1,217,544
s119118281
p04048
u541610817
1592159737
Python
Python (3.4.3)
py
Accepted
17
3060
347
def Z(): return int(input()) def ZZ(): return [int(_) for _ in input().split()] def main(): N, X = ZZ() N -= X ans = 0 while True: ans += (N//X) * 3 * X #割り切れない if N%X: N, X = X, N%X #割り切れる else: break print(ans) return if __name__ == '__main__': ma...
p04048
<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...
5 2
12
1,217,545
s132432380
p04048
u960080897
1590202074
Python
Python (3.4.3)
py
Accepted
18
3060
201
n, x = map(int, input().split()) def f(a, b): if (a > b): a, b = b, a if b % a == 0: return (b // a * 2 - 1) * a return b // a * 2 * a + f(b % a, a) print(n + f(x, n - x))
p04048
<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...
5 2
12
1,217,546
s109229200
p04048
u225388820
1590046336
Python
Python (3.4.3)
py
Accepted
17
3064
153
n,x=map(int,input().split()) ans=n n-=x n,x=max(n,x),min(n,x) ans+=2*(n//x)*x n%=x n,x=x,n while x: ans+=2*(n//x)*x n%=x n,x=x,n print(ans-n)
p04048
<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...
5 2
12
1,217,547
s830726603
p04048
u729133443
1589428414
Python
Python (3.8.2)
py
Accepted
20
9164
67
import math n,x=map(int,input().split()) print(3*(n-math.gcd(n,x)))
p04048
<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...
5 2
12
1,217,548
s296553858
p04048
u340781749
1588701850
Python
Python (3.4.3)
py
Accepted
17
2940
142
n, x = map(int, input().split()) a = n - x b = x ans = 0 while b: d, m = divmod(a, b) ans += d * b * 3 a = b b = m print(ans)
p04048
<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...
5 2
12
1,217,549
s501226448
p04048
u892487306
1588196716
Python
Python (3.4.3)
py
Accepted
17
3060
240
import math N, X = list(map(int, input().split(' '))) def f(a, b): a, b = min([a, b]), max([a, b]) if b % a == 0: return 2 * a * math.floor(b / a) - a return 2 * a * math.floor(b / a) + f(a, b % a) print(N + f(N - X, X))
p04048
<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...
5 2
12
1,217,550
s185286677
p04048
u994988729
1588034373
Python
Python (3.4.3)
py
Accepted
17
3060
182
def GCD(x, y): if y == 0: return x return GCD(y, x % y) if __name__ == "__main__": N, X = map(int, input().split()) ans = 3 * (N - GCD(N, X)) print(ans)
p04048
<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...
5 2
12
1,217,551
s394892081
p04048
u994988729
1588034122
Python
Python (3.4.3)
py
Accepted
17
3064
340
N, X = map(int, input().split()) if X * 2 == N: ans = 3 * X else: ans = 0 if X * 2 < N: LL = N - X SS = X else: LL = X SS = N - X while True: div, mod = divmod(LL, SS) ans += 3 * SS * div if mod == 0: break LL = SS ...
p04048
<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...
5 2
12
1,217,552
s258543943
p04048
u389910364
1587700248
Python
Python (3.4.3)
py
Accepted
17
3064
449
import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10 ** 9) INF = float("inf") IINF = 10 ** 18 MOD = 10 ** 9 + 7 # MOD = 998244353 N, K = list(map(int, sys.stdin.buffer.readline().split())) a = K b = N - K c = 0 d = min(a, b) while not a == b == c: a, b, c = ...
p04048
<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...
5 2
12
1,217,553
s432858311
p04048
u167988719
1587071583
Python
Python (3.4.3)
py
Accepted
18
3060
170
N, X = map(int, input().split()) def f(a, b): if b % a == 0: return b // a * 2 * a - a return b //a * 2 * a + f(b% a, a) ans = N + f(X, N-X) print(ans)
p04048
<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...
5 2
12
1,217,554
s757234374
p04048
u749416810
1586193913
Python
Python (3.4.3)
py
Accepted
18
3060
139
n,x=map(int,input().split()) a=max(n-x,x) b=min(n-x,x) s=n while b!=0: c=a//b d=a%b s+=2*b*c if d==0: s-=b a=b b=d print(s)
p04048
<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...
5 2
12
1,217,555
s548549815
p04048
u450956662
1585443563
Python
Python (3.4.3)
py
Accepted
18
3064
204
N, X = map(int, input().split()) a = max(N - X, X) b = min(N - X, X) ans = N while b != 0: q = a // b r = a % b ans += 2 * b * q if r == 0: ans -= b a = b b = r print(ans)
p04048
<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...
5 2
12
1,217,556
s725581679
p04048
u704284486
1585442942
Python
Python (3.4.3)
py
Accepted
19
3316
162
def gcd(a,b): while b:a,b = b,a%b return a def main(): N,X = map(int,input().split()) print(3*(N-gcd(N,X))) if __name__ == "__main__": main()
p04048
<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...
5 2
12
1,217,557
s799860145
p04048
u638795007
1584673298
Python
Python (3.4.3)
py
Accepted
38
4720
1,167
def examA(): N = I() L = LI() L.sort() ans = sum(L[::2]) print(ans) return def examB(): def gcd(x, y): if y == 0: return x while (y != 0): x, y = y, x % y return x N, X = LI() ans = 3*(N - gcd(N-X,X)) print(ans) return def exa...
p04048
<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...
5 2
12
1,217,558
s311004697
p04048
u561083515
1584455010
Python
Python (3.4.3)
py
Accepted
18
3060
230
# 解説AC N, X = map(int, input().split()) ans = N a, b = max(N - X , X), min(N - X, X) # Euclidの互除法 while b: q, r = divmod(a, b) ans += (b * 2) * q if r == 0: ans -= b # 最後 a, b = b, r print(ans)
p04048
<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...
5 2
12
1,217,559
s481092686
p04048
u189479417
1584411166
Python
Python (3.4.3)
py
Accepted
35
5048
100
import fractions N, X = map(int,input().split()) GCD = fractions.gcd(N, X) print(GCD*3*(N//GCD-1))
p04048
<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...
5 2
12
1,217,560
s030726620
p04048
u693716675
1583468772
Python
Python (3.4.3)
py
Accepted
17
3064
246
#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
p04048
<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...
5 2
12
1,217,561
s059552557
p04048
u729417323
1582558909
Python
Python (3.4.3)
py
Accepted
17
2940
151
# --*-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)
p04048
<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...
5 2
12
1,217,562
s935131823
p04048
u547167033
1582412028
Python
Python (3.4.3)
py
Accepted
36
5048
76
from fractions import gcd n,x=map(int,input().split()) print(3*(n-gcd(n,x)))
p04048
<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...
5 2
12
1,217,563
s056449306
p04048
u998008108
1582333657
Python
Python (3.4.3)
py
Accepted
49
5560
76
from fractions import gcd n,x=map(int,input().split()) print(3*(n-gcd(n,x)))
p04048
<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...
5 2
12
1,217,564
s068524854
p04048
u500297289
1581208204
Python
Python (3.4.3)
py
Accepted
35
5048
88
N, X = map(int, input().split()) from fractions import gcd print(3 * ( N - gcd(N, X)))
p04048
<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...
5 2
12
1,217,565
s156187298
p04048
u754022296
1580885631
Python
Python (3.4.3)
py
Accepted
17
3060
196
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)
p04048
<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...
5 2
12
1,217,566
s357671186
p04048
u606045429
1580708417
Python
Python (3.4.3)
py
Accepted
35
5048
86
from fractions import gcd N, X = map(int, input().split()) print(3 * (N - gcd(N, X)))
p04048
<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...
5 2
12
1,217,567
s664228161
p04048
u905582793
1578865598
Python
Python (3.4.3)
py
Accepted
17
3060
179
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)
p04048
<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...
5 2
12
1,217,568
s927215127
p04048
u102461423
1577432423
Python
Python (3.4.3)
py
Accepted
17
3188
389
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) ...
p04048
<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...
5 2
12
1,217,569
s021348992
p04048
u365375535
1577168890
Python
Python (3.4.3)
py
Accepted
19
3060
252
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()
p04048
<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...
5 2
12
1,217,570
s432672785
p04048
u532966492
1576898289
Python
Python (3.4.3)
py
Accepted
20
2940
190
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()
p04048
<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...
5 2
12
1,217,571
s584383797
p04048
u211706121
1576348979
Python
Python (3.4.3)
py
Accepted
17
3060
185
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)
p04048
<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...
5 2
12
1,217,572
s831954461
p04048
u020390084
1576297925
Python
Python (3.4.3)
py
Accepted
19
3064
619
#!/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(): ...
p04048
<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...
5 2
12
1,217,573
s385915610
p04048
u828766688
1576184433
Python
Python (3.4.3)
py
Accepted
17
3064
451
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 ...
p04048
<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...
5 2
12
1,217,574
s183083130
p04048
u497046426
1575597343
Python
Python (3.4.3)
py
Accepted
17
3064
229
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)
p04048
<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...
5 2
12
1,217,575
s924381346
p04048
u695197008
1574185117
Python
Python (2.7.6)
py
Accepted
10
2568
199
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
p04048
<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...
5 2
12
1,217,576
s819723548
p04048
u314050667
1573482027
Python
Python (3.4.3)
py
Accepted
19
3060
225
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))
p04048
<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...
5 2
12
1,217,577
s812852564
p04048
u729133443
1571460411
Python
Python (3.4.3)
py
Accepted
39
5304
73
from fractions import* n,x=map(int,input().split()) print(3*(n-gcd(n,x)))
p04048
<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...
5 2
12
1,217,578
s052510646
p04048
u393512980
1569210595
Python
Python (3.4.3)
py
Accepted
21
3444
384
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 = ...
p04048
<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...
5 2
12
1,217,579
s841063452
p04048
u588341295
1569109508
Python
Python (3.4.3)
py
Accepted
19
3188
1,038
# -*- 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...
p04048
<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...
5 2
12
1,217,580
s247693168
p04048
u227082700
1569109233
Python
Python (3.4.3)
py
Accepted
18
2940
96
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)
p04048
<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...
5 2
12
1,217,581
s415504689
p04048
u776715768
1569109217
Python
Python (3.4.3)
py
Accepted
17
2940
95
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)
p04048
<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...
5 2
12
1,217,582
s311931212
p04048
u588341295
1569108587
Python
Python (3.4.3)
py
Accepted
18
3064
1,038
# -*- 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...
p04048
<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...
5 2
12
1,217,583
s139965746
p04048
u322354465
1569098704
Python
Python (3.4.3)
py
Accepted
18
2940
391
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...
p04048
<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...
5 2
12
1,217,584
s506231618
p04048
u588341295
1568989417
Python
Python (3.4.3)
py
Accepted
52
5556
803
# -*- 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, ...
p04048
<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...
5 2
12
1,217,585
s504779492
p04048
u787059958
1568589924
Python
Python (3.4.3)
py
Accepted
19
3188
187
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)
p04048
<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...
5 2
12
1,217,586
s779236580
p04048
u480138356
1568004174
Python
Python (3.4.3)
py
Accepted
18
3064
371
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_ ...
p04048
<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...
5 2
12
1,217,587
s860314589
p04048
u874303957
1567277128
Python
Python (3.4.3)
py
Accepted
17
2940
156
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)
p04048
<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...
5 2
12
1,217,588
s683154326
p04048
u722535636
1567118226
Python
Python (3.4.3)
py
Accepted
17
3060
126
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)
p04048
<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...
5 2
12
1,217,589
s288208467
p04048
u102461423
1566964624
Python
Python (3.4.3)
py
Accepted
17
3064
354
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)
p04048
<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...
5 2
12
1,217,590
s804693083
p04048
u392319141
1566660902
Python
Python (3.4.3)
py
Accepted
21
3444
492
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,...
p04048
<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...
5 2
12
1,217,591
s134463842
p04048
u256868077
1566146669
Python
Python (3.4.3)
py
Accepted
17
3060
194
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)
p04048
<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...
5 2
12
1,217,592
s473109116
p04048
u670180528
1566086263
Python
Python (3.4.3)
py
Accepted
38
5304
73
from fractions import*;n,x=map(int,input().split());print(3*(n-gcd(n,x)))
p04048
<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...
5 2
12
1,217,593
s972318862
p04048
u670180528
1566086226
Python
Python (3.4.3)
py
Accepted
42
5048
73
from fractions import* n,x=map(int,input().split()) print(3*(n-gcd(n,x)))
p04048
<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...
5 2
12
1,217,594
s733850664
p04048
u670180528
1566086072
Python
Python (3.4.3)
py
Accepted
17
2940
100
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)
p04048
<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...
5 2
12
1,217,595
s516282759
p04048
u670180528
1566085760
Python
Python (3.4.3)
py
Accepted
17
3064
127
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)
p04048
<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...
5 2
12
1,217,596
s413387511
p04048
u571969099
1565796642
Python
Python (3.4.3)
py
Accepted
17
3060
129
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)
p04048
<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...
5 2
12
1,217,597
s129631581
p04048
u391731808
1565233406
Python
Python (3.4.3)
py
Accepted
17
3060
141
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)
p04048
<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...
5 2
12
1,217,598
s978395756
p04048
u800258529
1565121686
Python
Python (3.4.3)
py
Accepted
18
3060
280
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)
p04048
<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...
5 2
12
1,217,599
s900302027
p04048
u263830634
1563744819
Python
Python (3.4.3)
py
Accepted
17
3060
250
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)
p04048
<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...
5 2
12
1,217,600
s509274593
p04048
u889344512
1563693270
Python
Python (3.4.3)
py
Accepted
18
3060
240
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))
p04048
<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...
5 2
12
1,217,601
s554996164
p04048
u677523557
1563225097
Python
Python (3.4.3)
py
Accepted
19
3060
211
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)
p04048
<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...
5 2
12
1,217,602
s794365330
p04048
u623349537
1562630582
Python
Python (3.4.3)
py
Accepted
17
3060
473
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...
p04048
<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...
5 2
12
1,217,603
s349108191
p04048
u171366497
1561481706
Python
Python (3.4.3)
py
Accepted
17
2940
129
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)
p04048
<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...
5 2
12
1,217,604
s154517879
p04048
u097121858
1561032632
Python
Python (3.4.3)
py
Accepted
17
3060
427
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...
p04048
<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...
5 2
12
1,217,605
s451595171
p04048
u319818856
1560491722
Python
Python (3.4.3)
py
Accepted
18
3060
311
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)
p04048
<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...
5 2
12
1,217,606
s792312884
p04048
u017810624
1560152236
Python
Python (3.4.3)
py
Accepted
36
5048
76
from fractions import gcd n,x=map(int,input().split()) print(3*(n-gcd(n,x)))
p04048
<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...
5 2
12
1,217,607
s805954247
p04048
u332049206
1559245167
Python
Python (3.4.3)
py
Accepted
18
3188
162
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)
p04048
<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...
5 2
12
1,217,608
s362373879
p04048
u305052967
1559170653
Python
Python (3.4.3)
py
Accepted
21
3316
125
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)
p04048
<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...
5 2
12
1,217,609
s789912000
p04048
u163320134
1558931383
Python
Python (3.4.3)
py
Accepted
17
3060
167
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))
p04048
<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...
5 2
12
1,217,610
s874701479
p04048
u278886389
1558620692
Python
Python (3.4.3)
py
Accepted
21
3060
122
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)
p04048
<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...
5 2
12
1,217,611
s877696083
p04048
u346194435
1556037099
Python
Python (3.4.3)
py
Accepted
17
3064
346
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 ...
p04048
<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...
5 2
12
1,217,612
s068437222
p04048
u693716675
1555104300
Python
Python (3.4.3)
py
Accepted
18
3060
324
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...
p04048
<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...
5 2
12
1,217,613
s217425975
p04048
u684695949
1553826252
Python
Python (3.4.3)
py
Accepted
17
3064
303
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))
p04048
<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...
5 2
12
1,217,614
s720742160
p04048
u747873993
1553365412
Python
Python (3.4.3)
py
Accepted
17
2940
189
"""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)))
p04048
<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...
5 2
12
1,217,615
s578241618
p04048
u627417051
1553327418
Python
Python (3.4.3)
py
Accepted
17
3060
238
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)
p04048
<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...
5 2
12
1,217,616