Skip to content

Commit

Permalink
[auto-verifier] docs commit 9151361
Browse files Browse the repository at this point in the history
  • Loading branch information
web-flow authored May 31, 2024
1 parent a69557a commit e7d2414
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 104 deletions.
8 changes: 4 additions & 4 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ data:
- name: src/math
pages:
- icon: ':heavy_check_mark:'
path: src/math/FastGCD.hpp
title: src/math/FastGCD.hpp
path: src/math/BinaryGCD.hpp
title: Binary GCD
- name: src/modint
pages:
- icon: ':heavy_check_mark:'
Expand Down Expand Up @@ -84,8 +84,8 @@ data:
- name: test/math
pages:
- icon: ':heavy_check_mark:'
path: test/math/FastGCD.test.cpp
title: test/math/FastGCD.test.cpp
path: test/math/BinaryGCD.test.cpp
title: test/math/BinaryGCD.test.cpp
- name: test/modint
pages:
- icon: ':heavy_check_mark:'
Expand Down
104 changes: 73 additions & 31 deletions notebook.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ <h1 id="title">ICPC Notebook</h1>
</ol>
<li><a class="section" href="#math">math</a></li>
<ol>
<li><a href="#BinaryGCD.hpp">BinaryGCD.hpp</a></li>
</ol>
<li><a class="section" href="#modint">modint</a></li>
<ol>
Expand Down Expand Up @@ -223,6 +224,26 @@ <h2 id="FastSet.hpp">FastSet.hpp</h2>

<h2 class="section" id="math">math</h2>

<div class="filename">
<h2 id="BinaryGCD.hpp">BinaryGCD.hpp</h2>
md5: f3ab31

</div>
<div class="content content-hpp">
<pre><code>u64 <span class="token function">ctz</span><span class="token punctuation">(</span>u64 x<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token function">countr_zero</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token punctuation">}</span>
u64 <span class="token function">binary_gcd</span><span class="token punctuation">(</span>u64 x<span class="token punctuation">,</span> u64 y<span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span>x <span class="token operator">||</span> <span class="token operator">!</span>y<span class="token punctuation">)</span> <span class="token keyword">return</span> x <span class="token operator">|</span> y<span class="token punctuation">;</span>
u64 n <span class="token operator">=</span> <span class="token function">ctz</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span><span class="token punctuation">,</span> m <span class="token operator">=</span> <span class="token function">ctz</span><span class="token punctuation">(</span>y<span class="token punctuation">)</span><span class="token punctuation">;</span>
x <span class="token operator">>>=</span> n<span class="token punctuation">,</span> y <span class="token operator">>>=</span> m<span class="token punctuation">;</span>
<span class="token keyword">while</span><span class="token punctuation">(</span>x <span class="token operator">!=</span> y<span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>x <span class="token operator">></span> y<span class="token punctuation">)</span> x <span class="token operator">=</span> <span class="token punctuation">(</span>x <span class="token operator">-</span> y<span class="token punctuation">)</span> <span class="token operator">>></span> <span class="token function">ctz</span><span class="token punctuation">(</span>x <span class="token operator">-</span> y<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">else</span> y <span class="token operator">=</span> <span class="token punctuation">(</span>y <span class="token operator">-</span> x<span class="token punctuation">)</span> <span class="token operator">>></span> <span class="token function">ctz</span><span class="token punctuation">(</span>y <span class="token operator">-</span> x<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">return</span> x <span class="token operator">&lt;&lt;</span> <span class="token function">min</span><span class="token punctuation">(</span>n<span class="token punctuation">,</span> m<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
</div>

<h2 class="section" id="modint">modint</h2>

<div class="filename">
Expand Down Expand Up @@ -663,16 +684,6 @@ <h4>高度合成数</h4>
<td>768</td>
<td>1344</td>
</tr>
<tr>
<td>factor</td>
<td>3111</td>
<td>3311</td>
<td>33111</td>
<td>421111</td>
<td>631111</td>
<td>5311111</td>
<td>6321111</td>
</tr>
</tbody></table>
<table>
<thead>
Expand All @@ -684,6 +695,9 @@ <h4>高度合成数</h4>
<th>$10^{13}$</th>
<th>$10^{14}$</th>
<th>$10^{15}$</th>
<th>$10^{16}$</th>
<th>$10^{17}$</th>
<th>$10^{18}$</th>
</tr>
</thead>
<tbody><tr>
Expand All @@ -694,37 +708,65 @@ <h4>高度合成数</h4>
<td>10752</td>
<td>17280</td>
<td>26880</td>
</tr>
<tr>
<td>factor</td>
<td>53211111</td>
<td>63221111</td>
<td>642111111</td>
<td>6321111111</td>
<td>5422111111</td>
<td>64211111111</td>
<td>41472</td>
<td>64512</td>
<td>103680</td>
</tr>
</tbody></table>
<h4>素数階乗</h4>
<table>
<thead>
<tr>
<th>$≤n$</th>
<th>$10^{16}$</th>
<th>$10^{17}$</th>
<th>$10^{18}$</th>
<th>$n$</th>
<th>$2$</th>
<th>$3$</th>
<th>$5$</th>
<th>$7$</th>
<th>$11$</th>
<th>$13$</th>
<th>$17$</th>
<th>$19$</th>
<th>$23$</th>
<th>$29$</th>
</tr>
</thead>
<tbody><tr>
<td>$d^0(x)$</td>
<td>41472</td>
<td>64512</td>
<td>103680</td>
<td>$n\#$</td>
<td>2</td>
<td>6</td>
<td>30</td>
<td>210</td>
<td>2310</td>
<td>30030</td>
<td>510510</td>
<td>9699690</td>
<td>$2.2 \times 10^8$</td>
<td>$6.5 \times 10^9$</td>
</tr>
</tbody></table>
<h4>階乗</h4>
<table>
<thead>
<tr>
<td>factor</td>
<td>83221111111</td>
<td>632211111111</td>
<td>842211111111</td>
<th>$5!$</th>
<th>$6!$</th>
<th>$7!$</th>
<th>$8!$</th>
<th>$9!$</th>
<th>$10!$</th>
<th>$11!$</th>
<th>$12!$</th>
</tr>
</thead>
<tbody><tr>
<td>120</td>
<td>720</td>
<td>5040</td>
<td>40320</td>
<td>362880</td>
<td>3628800</td>
<td>$4.0 \times 10^7$</td>
<td>$4.8 \times 10^8$</td>
</tr>
</tbody></table>
</div>
Expand Down
Binary file modified notebook.pdf
Binary file not shown.
26 changes: 15 additions & 11 deletions src/math/FastGCD.hpp.md → src/math/BinaryGCD.hpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ data:
_extendedRequiredBy: []
_extendedVerifiedWith:
- icon: ':heavy_check_mark:'
path: test/math/FastGCD.test.cpp
title: test/math/FastGCD.test.cpp
path: test/math/BinaryGCD.test.cpp
title: test/math/BinaryGCD.test.cpp
_isVerificationFailed: false
_pathExtension: hpp
_verificationStatusIcon: ':heavy_check_mark:'
attributes:
links: []
bundledCode: "#line 1 \"src/math/FastGCD.hpp\"\nu64 ctz(u64 x) { return countr_zero(x);\
bundledCode: "#line 1 \"src/math/BinaryGCD.hpp\"\nu64 ctz(u64 x) { return countr_zero(x);\
\ }\nu64 binary_gcd(u64 x, u64 y) {\n if(!x || !y) return x | y;\n u64 n =\
\ ctz(x), m = ctz(y);\n x >>= n, y >>= m;\n while(x != y) {\n if(x >\
\ y) x = (x - y) >> ctz(x - y);\n else y = (y - x) >> ctz(y - x);\n }\n\
Expand All @@ -22,16 +22,20 @@ data:
\ else y = (y - x) >> ctz(y - x);\n }\n return x << min(n, m);\n}\n"
dependsOn: []
isVerificationFile: false
path: src/math/FastGCD.hpp
path: src/math/BinaryGCD.hpp
requiredBy: []
timestamp: '2024-05-31 23:58:41+09:00'
timestamp: '2024-06-01 01:21:46+09:00'
verificationStatus: LIBRARY_ALL_AC
verifiedWith:
- test/math/FastGCD.test.cpp
documentation_of: src/math/FastGCD.hpp
- test/math/BinaryGCD.test.cpp
documentation_of: src/math/BinaryGCD.hpp
layout: document
redirect_from:
- /library/src/math/FastGCD.hpp
- /library/src/math/FastGCD.hpp.html
title: src/math/FastGCD.hpp
title: Binary GCD
---

割り算を使わない高速な GCD

## 使い方

- `u64 binary_gcd(u64 x, u64 y)`:$x$ と $y$ の最大公約数を計算する.
- $O(\log(x + y))$ 時間
3 changes: 2 additions & 1 deletion src/modint/BarrettReduction.hpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ documentation_of: src/modint/BarrettReduction.hpp
layout: document
title: Barrett Reduction
---
- 参考実装:[AC Library](https://github.com/atcoder/ac-library/blob/master/atcoder/internal_math.hpp)

同じ mod でたくさん計算するとき,剰余算を掛け算に変換して高速化する.

## 使い方

- `Barrett br(mod)`:Barrett Reduction を準備する.
- 制約:`mod < 2^32`
- `br.mul(u64 a, u64 b)``a * b % mod` を計算する.
- `u64 br.mul(u64 a, u64 b)``a * b % mod` を計算する.
- 制約:`a * b < 2^64`

## 仕組み
Expand Down
1 change: 1 addition & 0 deletions src/modint/modint.hpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ documentation_of: src/modint/modint.hpp
layout: document
title: Modint
---
- 参考実装:[AC Library (初期実装)](https://github.com/atcoder/ac-library/blob/8250de484ae0ab597391db58040a602e0dc1a419/atcoder/convolution.hpp)

- タイプ速度重視の簡易 modint
- 速度が欲しいとき:[32 bit で加減算をちゃんと書いた Modint](../extra/modint_fast.hpp)
Expand Down
54 changes: 54 additions & 0 deletions test/math/BinaryGCD.test.cpp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
data:
_extendedDependsOn:
- icon: ':heavy_check_mark:'
path: src/math/BinaryGCD.hpp
title: Binary GCD
- icon: ':heavy_check_mark:'
path: test/template.hpp
title: test/template.hpp
_extendedRequiredBy: []
_extendedVerifiedWith: []
_isVerificationFailed: false
_pathExtension: cpp
_verificationStatusIcon: ':heavy_check_mark:'
attributes:
'*NOT_SPECIAL_COMMENTS*': ''
PROBLEM: https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_A
links:
- https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_A
bundledCode: "#line 1 \"test/math/BinaryGCD.test.cpp\"\n#define PROBLEM \"https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_A\"\
\n#line 1 \"test/template.hpp\"\n#include <bits/stdc++.h>\nusing namespace std;\n\
using ll = long long;\nconst ll INF = LLONG_MAX / 4;\n#define rep(i, a, b) for(ll\
\ i = a; i < (b); i++)\n#define all(a) begin(a), end(a)\n#define sz(a) ssize(a)\n\
bool chmin(auto& a, auto b) { return a > b ? a = b, 1 : 0; }\nbool chmax(auto&\
\ a, auto b) { return a < b ? a = b, 1 : 0; }\n#line 3 \"test/math/BinaryGCD.test.cpp\"\
\nusing u64 = uint64_t;\n#line 1 \"src/math/BinaryGCD.hpp\"\nu64 ctz(u64 x) {\
\ return countr_zero(x); }\nu64 binary_gcd(u64 x, u64 y) {\n if(!x || !y) return\
\ x | y;\n u64 n = ctz(x), m = ctz(y);\n x >>= n, y >>= m;\n while(x !=\
\ y) {\n if(x > y) x = (x - y) >> ctz(x - y);\n else y = (y - x) >>\
\ ctz(y - x);\n }\n return x << min(n, m);\n}\n#line 5 \"test/math/BinaryGCD.test.cpp\"\
\n\nint main() {\n mt19937_64 rnd;\n rep(shift, 0, 64) {\n rep(i, 0,\
\ (ll)1e5) {\n u64 a = rnd() >> shift, b = rnd() >> shift;\n assert(gcd(a,\
\ b) == binary_gcd(a, b));\n }\n }\n puts(\"Hello World\");\n}\n"
code: "#define PROBLEM \"https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_A\"\
\n#include \"test/template.hpp\"\nusing u64 = uint64_t;\n#include \"src/math/BinaryGCD.hpp\"\
\n\nint main() {\n mt19937_64 rnd;\n rep(shift, 0, 64) {\n rep(i, 0,\
\ (ll)1e5) {\n u64 a = rnd() >> shift, b = rnd() >> shift;\n assert(gcd(a,\
\ b) == binary_gcd(a, b));\n }\n }\n puts(\"Hello World\");\n}\n"
dependsOn:
- test/template.hpp
- src/math/BinaryGCD.hpp
isVerificationFile: true
path: test/math/BinaryGCD.test.cpp
requiredBy: []
timestamp: '2024-06-01 01:21:46+09:00'
verificationStatus: TEST_ACCEPTED
verifiedWith: []
documentation_of: test/math/BinaryGCD.test.cpp
layout: document
redirect_from:
- /verify/test/math/BinaryGCD.test.cpp
- /verify/test/math/BinaryGCD.test.cpp.html
title: test/math/BinaryGCD.test.cpp
---
54 changes: 0 additions & 54 deletions test/math/FastGCD.test.cpp.md

This file was deleted.

6 changes: 3 additions & 3 deletions test/template.hpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ data:
path: test/data-structure/FastSet.test.cpp
title: test/data-structure/FastSet.test.cpp
- icon: ':heavy_check_mark:'
path: test/math/FastGCD.test.cpp
title: test/math/FastGCD.test.cpp
path: test/math/BinaryGCD.test.cpp
title: test/math/BinaryGCD.test.cpp
- icon: ':heavy_check_mark:'
path: test/modint/BarrettReduction.test.cpp
title: test/modint/BarrettReduction.test.cpp
Expand Down Expand Up @@ -108,7 +108,7 @@ data:
- test/string/SuffixArray.test.cpp
- test/string/RollingHash.test.cpp
- test/string/Manacher.test.cpp
- test/math/FastGCD.test.cpp
- test/math/BinaryGCD.test.cpp
- test/modint/BarrettReduction.test.cpp
- test/modint/modint.test.cpp
documentation_of: test/template.hpp
Expand Down

0 comments on commit e7d2414

Please sign in to comment.