add _static
This commit is contained in:
174
storage/zeta/_static/13171.html
Normal file
174
storage/zeta/_static/13171.html
Normal file
@@ -0,0 +1,174 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>BOJ 13171 - Offline</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg: #fafaf8;
|
||||
--paper: #ffffff;
|
||||
--ink: #1e1f24;
|
||||
--muted: #6a6d75;
|
||||
--line: #d8dce3;
|
||||
--accent: #0d6e6e;
|
||||
--code-bg: #f4f6fb;
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
body {
|
||||
margin: 0;
|
||||
background:
|
||||
radial-gradient(circle at 15% 0%, #f0efe9 0%, transparent 42%),
|
||||
radial-gradient(circle at 85% 20%, #e7f1f2 0%, transparent 38%),
|
||||
var(--bg);
|
||||
color: var(--ink);
|
||||
font-family: "Noto Sans KR", "Pretendard", "Apple SD Gothic Neo", sans-serif;
|
||||
line-height: 1.65;
|
||||
}
|
||||
main {
|
||||
max-width: 980px;
|
||||
margin: 0 auto;
|
||||
padding: 24px 16px 56px;
|
||||
}
|
||||
.header {
|
||||
background: var(--paper);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 14px;
|
||||
padding: 18px 20px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.header h1 { margin: 0 0 6px; font-size: 1.5rem; }
|
||||
.header p { margin: 0; color: var(--muted); font-size: 0.95rem; }
|
||||
.header a { color: var(--accent); text-decoration: none; }
|
||||
.section {
|
||||
background: var(--paper);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 14px;
|
||||
padding: 16px 18px;
|
||||
margin-bottom: 14px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
h2 {
|
||||
margin: 0 0 10px;
|
||||
font-size: 1.05rem;
|
||||
color: var(--accent);
|
||||
border-bottom: 1px solid var(--line);
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
pre, code {
|
||||
font-family: "JetBrains Mono", "Fira Code", monospace;
|
||||
background: var(--code-bg);
|
||||
}
|
||||
pre {
|
||||
padding: 12px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid #e7ebf2;
|
||||
overflow: auto;
|
||||
}
|
||||
blockquote {
|
||||
margin: 14px 0;
|
||||
padding: 16px 16px 14px 22px;
|
||||
border-left: 4px solid var(--accent);
|
||||
border-radius: 10px;
|
||||
background: linear-gradient(90deg, #eef8f8 0%, #f9fdfd 100%);
|
||||
color: #24313a;
|
||||
font-weight: 600;
|
||||
position: relative;
|
||||
}
|
||||
blockquote::before {
|
||||
content: "“";
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
top: 2px;
|
||||
font-size: 1.35rem;
|
||||
line-height: 1;
|
||||
color: #0b5f5f;
|
||||
opacity: 0.7;
|
||||
}
|
||||
blockquote > :first-child { margin-top: 0; }
|
||||
blockquote > :last-child { margin-bottom: 0; }
|
||||
q {
|
||||
color: #114f50;
|
||||
font-weight: 700;
|
||||
background: #edf8f8;
|
||||
border-radius: 6px;
|
||||
padding: 0 4px;
|
||||
}
|
||||
.math-inline math {
|
||||
font-size: 1em;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.math-block {
|
||||
margin: 10px 0;
|
||||
padding: 8px 10px;
|
||||
overflow-x: auto;
|
||||
background: #f8fbff;
|
||||
border: 1px solid #e2ecf8;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.math-block math {
|
||||
font-size: 1.04em;
|
||||
display: block;
|
||||
}
|
||||
table { border-collapse: collapse; width: 100%; }
|
||||
th, td { border: 1px solid var(--line); padding: 6px 8px; }
|
||||
img { max-width: 100%; height: auto; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<header class="header">
|
||||
<h1>A</h1>
|
||||
</header>
|
||||
<article class="section">
|
||||
<h2>문제</h2>
|
||||
<p>음이 아닌 두 정수 A, X 가 있을 때 A<sup>X</sup>을 구하는 방법을 생각해보자. 물론 이 수는 매우 클 수 있기에, 1,000,000,007 (= 10<sup>9</sup> + 7)로 나눈 나머지를 구할 것이다. a mod x를 a를 x로 나눴을 때의 나머지라고 표현하면,</p>
|
||||
|
||||
<p style="text-align:center">(a × b) mod x = {(a mod x) × (b mod x)} mod x</p>
|
||||
|
||||
<p>가 성립하기 때문에, 어떤 두 정수를 1,000,000,007로 나눈 나머지만 알고 있어도 그 두 정수의 곱을 1,000,000,007로 나눈 나머지를 쉽게 계산할 수 있다.</p>
|
||||
|
||||
<p>본 문제로 돌아가서, 그렇다면 이제 A를 X 번 곱하면 A<sup>X</sup>을 쉽게 구할 수 있을 것 같아 보인다. 그러나 안타깝게도 X가 상당히 커서 64비트 정수의 범위에 있다면 A를 하나하나씩 곱하는 방식으로는 상상할 수 없을 정도로 긴 시간이 흘러야 답을 찾을 수 있을 것이다. 그래서 다음과 같이 곱셈의 횟수를 줄이는 방법을 사용한다.</p>
|
||||
|
||||
<ol>
|
||||
<li>먼저 A<sup>1</sup>, A<sup>2</sup>, A<sup>4</sup>, A<sup>8</sup>, ...을 순서대로 계산한다. 각 수는 이전에 있는 수를 제곱함으로써 계산할 수 있고, 지수가 X 를 딱 넘지 않을 시점까지만 계산하면 충분할 것이다. X가 64비트 정수의 범위에 있으므로 계산하는 수는 64개보다 작을 것이다.</li>
|
||||
<li>이제 X 를 이진수로 나타내 보자. 예를 들어 X를 11로 두면, X = 11 = 1 + 2 + 8이다. 그런데 지수법칙에 의해, A<sup>11</sup> = A<sup>1+2+8</sup> = A<sup>1</sup> × A<sup>2</sup> × A<sup>8</sup>이 성립한다. 이를 통해 1번 단계에서 미리 계산해 놓았던 수 몇 개만 곱해서 A<sup>X</sup> 을 계산할 수 있음을 알 수 있다.</li>
|
||||
</ol>
|
||||
|
||||
<p>즉, 차례로 A를 곱해 나간다면 시간이 X에 비례하게 걸리겠지만, 위의 방법을 이용하면 시간이 log(X)에 비례하게 걸리게 된다. A<sup>X</sup>를 구하는 프로그램을 작성하라.</p>
|
||||
</article>
|
||||
<article class="section">
|
||||
<h2>입력</h2>
|
||||
<p>첫 번째 줄에는 정수 A(1 ≤ A ≤ 10<sup>18</sup>)이 주어진다.</p>
|
||||
|
||||
<p>두 번째 줄에는 정수 X(1 ≤ X ≤ 10<sup>18</sup>)가 주어진다.</p>
|
||||
</article>
|
||||
<article class="section">
|
||||
<h2>출력</h2>
|
||||
<p>A<sup>X</sup>을 출력한다. 이 수는 매우 커질 수 있으므로 1,000,000,007로 나눈 나머지를 출력해야 한다.</p>
|
||||
</article>
|
||||
<article class="section">
|
||||
<h2>예제 입력 1 복사</h2>
|
||||
<pre class="sampledata" id="sample-input-1">3
|
||||
3
|
||||
</pre>
|
||||
</article>
|
||||
<article class="section">
|
||||
<h2>예제 입력 2 복사</h2>
|
||||
<pre class="sampledata" id="sample-input-2">100
|
||||
100
|
||||
</pre>
|
||||
</article>
|
||||
<article class="section">
|
||||
<h2>예제 출력 1 복사</h2>
|
||||
<pre class="sampledata" id="sample-output-1">27
|
||||
</pre>
|
||||
</article>
|
||||
<article class="section">
|
||||
<h2>예제 출력 2 복사</h2>
|
||||
<pre class="sampledata" id="sample-output-2">424090053
|
||||
</pre>
|
||||
</article>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user