submission_id string | problem_id string | status string | code string | input string | output string | problem_description string |
|---|---|---|---|---|---|---|
s660993826 | p04048 | Wrong Answer | def gcd(a,b):
return a and gcd(b%a,a)or b
N,X=map(int,input().split())
g=gcd(N,X)
z=N//g
b=(N-X)//g
a=min(X,N-X)//g
while a>1:
c=b
while c:
z+=2*a
c//=a
a,b=b%a,a
print(g*(z-1))
| 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s146736681 | p04048 | Wrong Answer | x,y=map(int,input().split())
z=3.5*y+x
print(z) | 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s292849948 | p04048 | Wrong Answer | n, x = map(int, input().split())
sum_lec = x + (n - x) + x + x +(n - 2 * x) * 3
print(sum_lec) | 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s828235794 | p04048 | Wrong Answer | def trajectory_cal(N, X):
length = 4*N - 4*X
return length
N, X = input().split()
value = trajectory_cal(int(N), int(X))
print(value) | 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s899469918 | p04048 | Wrong Answer | N,X = [int(zz) for zz in input().split()]
print(6*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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s379512034 | p04048 | Wrong Answer | # import numpy as np
import sys
sys.setrecursionlimit(10 ** 5)
N, X = map(int, input().split())
if N > 1000:
exit()
if 2 * X > N:
X = N - X
#座標の作成
dp = [[-1] * (N+3)]
for i in range(N+1):
tmp = [-1]
for j in range(N+1):
if i <= j:
tmp.append(0) #到達していないマス
else:
tmp.append(-1) #壁(範囲外)
tmp.append(-1)
tmp.reverse()
dp.append(tmp)
dp.append([-1] * (N+3))
# print (np.array(dp))
#m: 0:右へ, 1:左下へ, 2:左上へ
def moving(x, y, total, m):
if x == X and y == 1 and dp[x][y] == 1:
# print ('D')
return total
if m == 0: #右に動く時
tmp = 0
while dp[x-1][y+1] == 0: #右に進める時
dp[x-1][y+1] = 1 #右進んだマスを到達したことにする
tmp += 1
x -= 1
y += 1
if dp[x-1][y+1] == -1: #右側が壁の時-->左下に進む
# print ('1-B')
return moving(x, y, total + tmp, 1)
if dp[x-1][y+1] == 1: #右側が光の線の時-->左上へ進む
tmp += 1
# print ('1-C')
return moving(x-1, y+1, total + tmp, 2)
if m == 1: #左下へ動く時
tmp = 0
while dp[x+1][y] == 0: #左下に進める時
dp[x+1][y] = 1
tmp += 1
x += 1
if dp[x+1][y] == -1: #左下が壁の時-->左上に進む
# print ('2-C')
return moving(x, y, total + tmp, 2)
if dp[x+1][y] == 1: #左下が光の線の時-->左上に進む
tmp += 1
# print ('2-C')
return moving(x+1, y, total + tmp, 2)
if m == 2: #左上に動く時
tmp = 0
while dp[x][y-1] == 0: #左上に進める時
dp[x][y-1] = 1
tmp += 1
y -= 1
if dp[x][y-1] == -1: #左上が壁の時-->右に進む
# print ('3-A')
return moving(x, y, total + tmp, 0)
if dp[x][y-1] == 1: #左上が光の線の時-->左下に進む
tmp += 1
# print ('3-B')
return moving(x, y-1, total + tmp, 1)
X += 1
print (moving(X, 1, 0, 0))
# print (np.array(dp)) | 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s949297241 | p04048 | Wrong Answer | 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-1
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s787194007 | p04048 | Wrong Answer | N, X = map(int, input().split())
if 2 * X > N:
X = N - X
# if N == 2 * X:
# print (3 * X)
# exit()
# if X == 1:
# print (3 * X * (N - 1))
# exit()
# if X == 2:
# print (3 * X * 2)
# exit()
x = 3 * X
n = (N - 1)//X
print (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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s164264081 | p04048 | Wrong Answer | n, x = list(map(int, input().split()))
ans = x
a = x
b = n - x
while b > 0:
ans += (a // b) * 2 * b
if a % b > 0:
ans += 1
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s073619898 | p04048 | Wrong Answer | a, b = map(int, input().split())
print(a * 2 + 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s434517532 | p04048 | Wrong Answer | def is_prime(n: int)->bool:
d = 2
while d * d <= n:
if n % d == 0:
return False
d += 1
return True
def mysterious_light(N: int, X: int)->int:
if is_prime(N):
return 3*(N-1)
return 3*max(N-X, X)
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s780811728 | p04048 | Wrong Answer | def is_prime(n: int)->bool:
d = 2
while d * d <= n:
if n % d == 0:
return False
d += 1
return True
def mysterious_light(N: int, X: int)->int:
if is_prime(N):
return 3*(N-1)
return 3*(N-X)
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s388156638 | p04048 | Wrong Answer | N,X = map(int, input().split())
def para(a,b):
if a == b:
return a
else:
if a%b == 0:
return (2*(a//b) -1)*b
if a%b != 0:
return (2*(a//b) -1)*b + para(b,a%b)
if X >= N-X:
print(N+para(X,N-X))
else:
print(N+para(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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s803960281 | p04048 | Wrong Answer | N,X = map(int, input().split())
def para(a,b):
if a == b:
return a
else:
if a%b == 0:
return (2*(a//b) -1)*b
if a%b != 0:
return (2*(a//b) -1)*b + para(b,a%b)
if X >= N-X:
print(N+para(X,N-X))
if X <= N-X:
print(N+para(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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s438275531 | p04048 | Wrong Answer | N,X = map(int, input().split())
def para(a,b):
if a == b:
return a
else:
if a%b == 0:
return (2*a//b -1)*b
if a%b != 0:
return (2*a//b -1)*b + para(b,a%b)
if X >= N-X:
print(N+para(X,N-X))
else:
print(N+para(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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s856713547 | p04048 | Wrong Answer | N,X = map(int, input().split())
def para(a,b):
if a == b:
return a
else:
if a%b == 0:
return (2*a//b -1)*b
if a%b != 0:
return (2*a//b -1)*b + para(b,a%b)
if X >= N-X:
print(N+para(X,N-X))
if X <= N-X:
print(N+para(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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s733403426 | p04048 | Wrong Answer | 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
print(x,y)
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s891475221 | p04048 | Wrong Answer | def calc(a,b,ans):
if b==0:
return ans
else:
if b!=1:
return calc(b,a%b,ans+b*3)
else:
return calc(b,a%b,ans+a*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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s044963083 | p04048 | Wrong Answer | def calc(a,b,ans):
if b==0:
return ans
else:
if b!=1:
return calc(b,a%b,ans+b*3)
else:
return calc(b,a%b,ans+a*3)
n,x=map(int,input().split())
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s100546763 | p04048 | Wrong Answer | N, X = map(int, input().split())
print((N-1)*3) | 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s500582302 | p04048 | Wrong Answer | n,x=map(int,input().split())
ans=0
if x<n/2:
a=x
b=n-x
ans+=n-x
while True:
if b%a==0:
ans+=a*2*(b//a)
break
else:
ans+=a*2*(b//a)
a,b=b%a,a
elif x==n/2:
ans=3*x
elif x>n/2:
a=n-x
b=x
ans+=x
while True:
if b%a==0:
ans+=a*2*(b//a)
break
else:
ans+=a*2*(b//a)
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s375652488 | p04048 | Wrong Answer | n,x=map(int,input().split())
ans=0
if x<n/2:
a=x
b=n-x
ans+=x+n
while True:
if b%a==0:
ans+=a*2*(b//a-1)
break
else:
ans+=a*2*(b//a)
a,b=b%a,a
elif x==n/2:
ans=3*x
elif x>n/2:
a=n-x
b=x
ans+=x
while True:
if b%a==0:
ans+=a*2*(b//a)
break
else:
ans+=a*2*(b//a)
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s901611092 | p04048 | Wrong Answer | n,x=map(int,input().split())
ans=0
if x<n/2:
a=x
b=n-x
ans+=x+n
while True:
if b%a==0:
ans+=a*2*(b/a)
break
else:
ans+=a*2*(b//a)
a,b=b%a,a
elif x==n/2:
ans=3*x
elif x>n/2:
a=n-x
b=x
ans+=x
while True:
if b%a==0:
ans+=a*2*(b/a)
break
else:
ans+=a*2*(b//a)
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s078904079 | p04048 | Wrong Answer | n,m=map(int,input().split())
print(n//2*3 if n/2==m else n*3-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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s276456976 | p04048 | Wrong Answer | n,m=map(int,input().split())
print(n//2*3 if n//2==m else n*3-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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s621534239 | p04048 | Wrong Answer | n,m=map(int,input().split())
print(n*3-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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s769947366 | p04048 | Wrong Answer | 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(cnt)
| 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s405000975 | p04048 | Wrong Answer | N, X = map(int, input().split())
print(X * 6) | 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s408087727 | p04048 | Wrong Answer | 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)
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s923560019 | p04048 | Wrong Answer | 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
if n % 2 == 0:
print(total)
else:
print(total - 1) | 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s337533766 | p04048 | Wrong Answer | 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 - 1) | 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s105471540 | p04048 | Wrong Answer | n,x=map(int,raw_input().split())
if n<x:
tmp=n
n=x
x=tmp
print 3*(n-1) | 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s531609943 | p04048 | Wrong Answer | n,x=map(int,raw_input().split())
print 3*(n-1) | 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s320666076 | p04048 | Wrong Answer | 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) + 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s715303468 | p04048 | Wrong Answer | 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) + f(b%a,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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s642017979 | p04048 | Wrong Answer | n, x = map(int, input().split())
i = n - x
j = 1
ret = x
while (i > 0):
ret += i*j
i -= 1
j += 1
print(ret)
| 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s163263304 | p04048 | Wrong Answer | #!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(): return list(sys.stdin.readline())[:-1]
def IR(n):
l = [None for i in range(n)]
for i in range(n):l[i] = I()
return l
def LIR(n):
l = [None for i in range(n)]
for i in range(n):l[i] = LI()
return l
def SR(n):
l = [None for i in range(n)]
for i in range(n):l[i] = S()
return l
def LSR(n):
l = [None for i in range(n)]
for i in range(n):l[i] = SR()
return l
mod = 1000000007
#A
"""
n = I()
l = LI()
l.sort()
ans = 0
for i in range(n):
ans += l[2*i]
print(ans)
"""
#B
n,x = LI()
print((n-1)*3)
#C
#D
#E
#F
#G
#H
#I
#J
#K
#L
#M
#N
#O
#P
#Q
#R
#S
#T
| 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s392769165 | p04048 | Wrong Answer | 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)
| 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s573674066 | p04048 | Wrong Answer | 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:
print(c1)
c2=c1+2*b1*q-b1
print(c2)
return c2
else:
count=count+1
c2=c1+2*b1*q
a2=a1-b1*q
b2=b1
if(a2<b2):
a2,b2=b2,a2
return calc_path(a2,b2,c2)
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s181561582 | p04048 | Wrong Answer | 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+1
return c2
else:
count=count+1
c2=c1+2*b1*q
a2=a1-b1*q
b2=b1
if(a2<b2):
a2,b2=b2,a2
return calc_path(a2,b2,c2)
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s860269408 | p04048 | Wrong Answer | 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+b1*(q+1)
return c2
else:
count=count+1
c2=c1+b1*(q+1)
a2=a1-b1*q
b2=b1
if(a2<b2):
a2,b2=b2,a2
return calc_path(a2,b2,c2)
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s299217751 | p04048 | Wrong Answer | N, X = map(int, input().split())
print(4 * int(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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s627215655 | p04048 | Wrong Answer | N, X = map(int, input().split())
print(X * 6) | 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s573973190 | p04048 | Wrong Answer | n, x = map(int, input().split())
if n % 2:
print((n-1)*3)
else:
print(max(n-x, 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s736007811 | p04048 | Wrong Answer | n, x = map(int, input().split())
if n % 2:
print(3 * (n - 1))
else:
if x <= n // 2:
print(3 * (n - x))
else:
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s449334981 | p04048 | Wrong Answer | N, X = [int(n) for n in input().split()]
l = N - X
s = X
cost = N
while(l % s != 0):
cost += 2 * s
l, s = s, l - s
print(cost + l + 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s136913283 | p04048 | Wrong Answer | def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a%b)
n, x = map(int, input().split())
print(3*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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s561951220 | p04048 | Wrong Answer | #x, N-x, x
#N-x-x
N,x = list(map(int, input().split()))
ll = 0
if x*2 < N:
ll = x + N
if (N-x*2) == x:
ll += 2*x
elif (N-2*x) > x:
ll += (N-x*2)/x * 2*x
else :
ll += x + x/(N-x*2)*2-(N-x*2)
elif x*2 == N:
ll = x + x + x
else:
ll = x
ll += x/(N-x)*2*(N-x)
print(int(ll))
| 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s088348921 | p04048 | Wrong Answer | #x, N-x, x
#N-x-x
N,x = list(map(int, input().split()))
ll = 0
if x*2 < N:
ll = x + N
if (N-x*2) == x:
ll += 2*x
elif (N-2*x) > x:
ll += (N-x*2)/x * 2*x
else :
ll += x + x/(N-x*2)*2-(N-x*2)
elif x*2 == N:
ll = x + x + x
else:
ll = x
ll += x/(N-x)*2
print(int(ll))
| 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s593831199 | p04048 | Wrong Answer | 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*2-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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s370842368 | p04048 | Wrong Answer | import sys
sys.setrecursionlimit(10**7)
N,X=map(int,input().split())
def f(a,b):
if a>b:
return f(b,a)
if a==b:
return a
if a==0:
return 0
if a==1:
return b
return 2*a*(b//a)+f(b%a,b)
print(N+f(X,N-X))
#print(f(3,2),f(3,1)) | 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s622072658 | p04048 | Wrong Answer | a,b = map(int,input().split())
if b < (a-b):
print(4*a-4*b)
else:
print(4*a-3*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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s995536695 | p04048 | Wrong Answer | n,x = (int(i) for i in input().split())
if 2*x ==n :ans = 3*x
else:ans = 4*x +4*abs((n-2*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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s647426804 | p04048 | Wrong Answer | a = input().rstrip().split(" ")
N = int(a[0])
X = int(a[1])
l = X * 4 + (N - 2 * X) * 4
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s738463034 | p04048 | Wrong Answer | li = [int(i) for i in input().split(" ")]
res = (li[0]-1) * 3
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s715961598 | p04048 | Wrong Answer | N,X = map(int,input().split())
ans = 2*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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s805855603 | p04048 | Wrong Answer | import sys
sys.setrecursionlimit(100000)
def inpl(): return list(map(int, input().split()))
N, X = map(int, input().split())
def calc(A, B, i):
d, m = divmod(A, B)
if m == 0:
tmp = (2*d-(i != 0))*B
return tmp
else:
tmp = (2*d+1-(i!=0))*B
tmp += calc(B, m, (i+1)%3)
return tmp
ans = calc(X, N-X, 0) + 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s797683063 | p04048 | Wrong Answer | import sys
sys.setrecursionlimit(1000000)
def inpl(): return list(map(int, input().split()))
N, X = map(int, input().split())
def calc(A, B, i):
d, m = divmod(A, B)
if m == 0:
tmp = (2*d-(i%3 > 0))*B
return tmp
else:
tmp = (2*d+1-i)*B
tmp += calc(B, m, (i+1)%3)
return tmp
ans = calc(X, N-X, 0) + 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s036340270 | p04048 | Wrong Answer | 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()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
def gcd(a,b):
if a%b == 0:
return b
else:
return gcd(b, a%b)
def rec(a: int, b: int) -> int:
mx = max(a,b)
mn = min(a,b)
if gcd(a,b) == mn:
return (2 * (mx // mn) - 1) * mn
else:
return (2 * (mx // mn) * mn) + rec(mn, mn * (mx // mn))
n,x = li()
print(n + 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s168943368 | p04048 | Wrong Answer | n,x= list(map(int,input().split(" ")))
y = n-x
s = n
while x % y !=0 or y % x != 0 :
if x>y:
s +=2* (x//y)
x %= y
else:
s += 2*(y//x)
y %= x
if x*y==0:
break
s+= x+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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s926180917 | p04048 | Wrong Answer | N, X = map(int ,input().split())
if X==N/2:
print(3*X)
else :
if X>N/2:
X = N-X
L = X + (N-X) + X
rest_ab = N-2*X
while rest_ab > X:
L += 2*X
# print('>X',L)
rest_ab -= X
if rest_ab == X:
L += 2*X
elif rest_ab < X:
# print('rest_ab=', rest_ab)
L += X + 2*(X-1) + 1
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s513457636 | p04048 | Wrong Answer | value = input()
values = value.split()
N = int( values[0] )
X = int( values[1] )
shorter = min([X,N-X])
longer = max([X,N-X])
length = 0
while shorter>0 and longer >0 :
length = int(longer/shorter)*3*shorter
sho = longer/shorter
amari = longer%shorter
longer = shorter
shorter = amari
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s942903940 | p04048 | Wrong Answer | import sys
value = input()
values = value.split()
N = int( values[0] )
X = int( values[1] )
#N = int(sys.argv[1])
#X = int(sys.argv[2])
#print(sys.argv)
rect = [ X, N-X ]
rect_temp = rect
length = 0
while rect_temp[0] > 0 and rect_temp[1] > 0 :
if rect_temp[0] < rect_temp[1]:
length += rect_temp[0]*3
rect_temp = [ rect_temp[0], rect_temp[1]-rect_temp[0] ]
elif rect_temp[0] >= rect_temp[1]:
length += rect_temp[1]*3
rect_temp = [ rect_temp[0] - rect_temp[1], rect_temp[0] ]
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s437465010 | p04048 | Wrong Answer | value = input()
values = value.split()
N = int( values[0] )
X = int( values[1] )
rect = [ X, N-X ]
rect_temp = rect
length = 0
while True :
if rect_temp[0] < rect_temp[1]:
length += rect_temp[0]*3
rect_temp = [ rect_temp[0], rect_temp[1]-rect_temp[0] ]
elif rect_temp[0] > rect_temp[1]:
length += rect_temp[1]*3
rect_temp = [ rect_temp[0] - rect_temp[1], rect_temp[0] ]
elif rect_temp[0] == rect_temp[1]:
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s779272697 | p04048 | Wrong Answer | # 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s663435651 | p04048 | Wrong Answer | # 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)
L += x*k
# print(x, y, k, L)
y, x = (x, y-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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s178776627 | p04048 | Wrong Answer | from math import floor
N, X = [int(x) for x in input().split()]
print(N, X)
x0 = N
x1 = X
x2 = x0-x1
L = 2*X
c = 1
while x2 > 0:
k = floor(x0/(x1/2))-1
L += x1*k
x0, x1, x2 = (x1, x2, x0-x1)
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s215261349 | p04048 | Wrong Answer | N,X = map(int,input().split())
ans = X + (N-X) + X*2 + (N-2*X)*3
print(ans)
#print(X,N-X,X,N-2*X,N-2*X,N-2*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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s318929054 | p04048 | Wrong Answer | 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-1
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s592824914 | p04048 | Wrong Answer | N, X = map(int, input().split())
if X == N//2:
print(N//2 * 3)
elif N % X == 0:
a = max(N-X, X)
b = min(N-X, X)
print(a + a // b * 2)
else:
print(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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s787945232 | p04048 | Wrong Answer | 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-1
else:
return func(b,a)
N,X = map(int,input().split())
dis =N
dis += func(N-X,X)
print(dis) | 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s391952222 | p04048 | Wrong Answer | #最大公約数
def gcd(a,b):
if a==b:
return b
elif b==1:
return 1
else:
return gcd(b,a%b)
def func(a,b):
if a<=b :
if b%a > 0:
return 2*(b//a)*a+func(a,b%a)
else:
return 2*(b//a)*a-1
else:
return func(b,a)
N,X = map(int,input().split())
dis =N
dis += func(N-X,X)
print(dis) | 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s728356052 | p04048 | Wrong Answer | n,x=map(int,input().split())
print(n*24/10) | 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s741251563 | p04048 | Wrong Answer | n,x=map(int,input().split())
print(x+(n-x)+x+x+(n/2)*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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s177768964 | p04048 | Wrong Answer | n,x=map(int,input().split())
print(int(n + (7*x) / 2)) | 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s874964161 | p04048 | Wrong Answer | N,X=map(int, input().split())
ans=0
if X ==N/2:
ans = 3*N/2
elif X> N/2:
ans = 3*X
else:
ans = 3*X + X + 2*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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s007082882 | p04048 | Wrong Answer | n,x = map(int,input().split())
if x == n/2:
ans = x*3
else:
ans = (n-1)*3
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s197720527 | p04048 | Wrong Answer | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
def light_length(a:int, b:int) -> int:
if a > b:
a,b = b,a
if b%a == 0:
return 2 * (b//a) - a
return 2 * (b//a) * a + light_length(a, b%a)
n,x = li()
print(n + light_length(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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s905854439 | p04048 | Wrong Answer | from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]
def inside(y, x, H, W):
return 0 <= y < H and 0 <= x < W
def ceil(a, b):
return (a + b - 1) // b
# aとbの最大公約数
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
# aとbの最小公倍数
def lcm(a, b):
g = gcd(a, b)
return a / g * b
def main():
N, X = map(int, input().split())
ans = (3 * X)
if X % 2 == 0 and N % 2 == 0:
ans += (N - (X + 2)) * 3
else:
ans += (N - (X + 1)) * 3
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s767069642 | p04048 | Wrong Answer | n,x=map(int,input().strip().split())
y=n-x
an=y+x*3+(n-2*x)*3
print(an) | 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s010136535 | p04048 | Wrong Answer | n,x=map(int,input().strip().split())
y=n-x
an=y+x*3+x/2*3
print(an) | 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s429823440 | p04048 | Wrong Answer | import sys
def main():
n, x = map(int, input().split(' '))
print((n-x)*3)
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s838415596 | p04048 | Wrong Answer | a,b = map(int,input().split())
s = a/b
print(3*b*(s-1)) | 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s245218189 | p04048 | Wrong Answer | n, x = map(int, input().split())
if n % x == 0:
nn = int(n / x)
print((nn - 1)* 3 *x)
else:
print((n-1)*3)
| 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s924209593 | p04048 | Wrong Answer | n, x = map(int, input().split())
if n / x == 2:
print(x*3)
else:
print((n-1)*3) | 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s759293452 | p04048 | Wrong Answer | n, x = map(int, input().split())
if int(n / x) == (n / x):
print(x*3)
else:
print(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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s479814691 | p04048 | Wrong Answer | n, x = map(int, input().split())
if n / x == 2:
print(x*3)
else:
print(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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s755534772 | p04048 | Wrong Answer | n,m=map(int,input().split())
print(int(3*(n-1)) if (n-1)%2==0 else int(abs(m-n/2)*3+3*(n)/2)) | 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s289917534 | p04048 | Wrong Answer | n,m=map(int,input().split())
print(3*n if n%2==0 else abs(m-(n+1)/2)*3+3*(n+1)/2) | 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s411933676 | p04048 | Wrong Answer | n,x = map(int,input().split())
print((x+n%(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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s663659593 | p04048 | Wrong Answer | n,x = map(int,input().split())
if n % x == 0 or n % (n-x) == 0:
print(max(x,n-x) * 3)
else:
print(min(x,n-x) * 6) | 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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s733657091 | p04048 | Wrong Answer | n,x = map(int,input().split())
print(3*min(x,n-x) * (1 + min(n%(n-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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s946372486 | p04048 | Wrong Answer | n,x = map(int,input().split())
print(3 * max(n-x,x) + 3 * (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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s735459848 | p04048 | Wrong Answer | n,x = map(int,input().split())
print(3 * (n-x) + 3 * (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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s248871649 | p04048 | Wrong Answer | L = input()
L = L.split()
n = int(L[0])
x = int(L[1])
if (n % 2 == 1):
print(3*(n-1))
else:
if (x < n/2):
print(int(3*(n-1)-(n/2)*(x-1)))
elif(x == n/2):
print(int(3*x))
else:
print(int(3*(n-1)-(n/2)*(n-x-1)))
| 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s919439470 | p04048 | Wrong Answer | N,X = map(int,input().split())
print(N*3-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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s908573544 | p04048 | Wrong Answer | N, X = map(int, input().split())
path = N
a, b = X, N - X
if a < b:
a, b = b, a
while b > 0:
print(a, b)
path += b * (a // b) * 2
a, b = b, a % b
path -= a
print(path) | 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s847397379 | p04048 | Wrong Answer | n, x = map(int, input().split())
#divs = [x]
ans = n
while n % x != 0:
ans += 2 * (n // x) * x
n , x = x, n % x
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s569235684 | p04048 | Wrong Answer | n, x = map(int, input().split())
#divs = [x]
ans = n
while n % x != 0:
ans += 2 * ((n - 1) // x) * x
n , x = x, n % x
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 equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
s362282024 | p04048 | Wrong Answer | [N, X] = list(map(int, input().split()))
if(X == N/2):
print(int(N*3/2))
else:
print(int((N-1)*3))
| 5 2
| 12
| <span class="lang-en">
<p>Score : <var>500</var> points</p>
<div class="part">
<section>
<h3>Problem Statement</h3><p>Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of <em>Mysterious Light</em>.</p>
<p>Three mirrors of length <var>N</var> are set so that they form an equilateral triangle.
Let the vertices of the triangle be <var>a, b</var> and <var>c</var>.</p>
<p>Inside the triangle, the rifle is placed at the point <var>p</var> on segment <var>ab</var> such that <var>ap = X</var>.
(The size of the rifle is negligible.)
Now, the rifle is about to fire a ray of Mysterious Light in the direction of <var>bc</var>.</p>
<p>The ray of Mysterious Light will travel in a straight line, and will be reflected by mirrors, in the same ways as "ordinary" light.
There is one major difference, though: it will be also reflected by its own trajectory as if it is a mirror!
When the ray comes back to the rifle, the ray will be absorbed.</p>
<p>The following image shows the ray's trajectory where <var>N = 5</var> and <var>X = 2</var>.</p>
<div style="text-align: center;">
<img alt="btriangle.png" src="https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/btriangle.png">
</img></div>
<p>It can be shown that the ray eventually comes back to the rifle and is absorbed, regardless of the values of <var>N</var> and <var>X</var>.
Find the total length of the ray's trajectory.</p>
</section>
</div>
<div class="part">
<section>
<h3>Constraints</h3><ul>
<li><var>2≦N≦10^{12}</var></li>
<li><var>1≦X≦N-1</var></li>
<li><var>N</var> and <var>X</var> are integers.</li>
</ul>
</section>
</div>
<div class="part">
<section>
<h3>Partial Points</h3><ul>
<li><var>300</var> points will be awarded for passing the test set satisfying <var>N≦1000</var>.</li>
<li>Another <var>200</var> points will be awarded for passing the test set without additional constraints.</li>
</ul>
</section>
</div>
<hr/>
<div class="io-style">
<div class="part">
<section>
<h3>Input</h3><p>The input is given from Standard Input in the following format:</p>
<pre><var>N</var> <var>X</var>
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Output</h3><p>Print the total length of the ray's trajectory.</p>
</section>
</div>
</div>
<hr/>
<div class="part">
<section>
<h3>Sample Input 1</h3><pre>5 2
</pre>
</section>
</div>
<div class="part">
<section>
<h3>Sample Output 1</h3><pre>12
</pre>
<p>Refer to the image in the Problem Statement section.
The total length of the trajectory is <var>2+3+2+2+1+1+1 = 12</var>.</p></section>
</div>
</span> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.