diff options
Diffstat (limited to 'archive/q/base32/a/20/index.html')
| -rw-r--r-- | archive/q/base32/a/20/index.html | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/archive/q/base32/a/20/index.html b/archive/q/base32/a/20/index.html new file mode 100644 index 0000000..7efb546 --- /dev/null +++ b/archive/q/base32/a/20/index.html @@ -0,0 +1,168 @@ +<!DOCTYPE html> +<html> + <head> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>問題 #2 - 回答 #20 | Albatross.PHP</title> + <link rel="stylesheet" href="../../../../assets/index.css"> + <link rel="icon" type="image/svg+xml" href="../../../../assets/favicon.svg"> + <script type="module" src="../../../../assets/index.js"></script> + </head> + <body> + <header class="container"> + <nav class="navbar"> + <a class="navbar-brand" href="../../../../index.html">Albatross.PHP</a> + </nav> + </header> + <main class="container mt-5"> + <h1 class="mb-4">問題 #2 - 回答 #20</h1> + <nav> + <ol class="breadcrumb"> + <li class="breadcrumb-item"><a href="../../../../index.html">問題一覧</a></li> + <li class="breadcrumb-item"><a href="../../index.html">Base32</a></li> + <li class="breadcrumb-item"><a href="../index.html">回答一覧</a></li> + <li class="breadcrumb-item active">#20</li> + </ol> + </nav> + + <h2>Base32</h2> + <p> + RFC 4648 で定義された Base32 エンコーディングを実装してください。
+標準入力から与えられる各行に対し、Base32 エンコードをおこなった文字列を標準出力へ改行区切りで出力してください。
+なお、アルファベットの出力には大文字を用いてください。 + </p> + <h2>回答 #20</h2> + <p> + yamamoto-hiroya が 2024-03-07 23:25:32 に投稿 + </p> + <h2>コード</h2> + <p> + 446 byte + </p> + <pre><code class="hljs language-php">const A='ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
+while($l=trim(fgets(STDIN))){
+ $b=$c='';
+ for($i=0;$i++<strlen($l);){
+ $b.=str_pad(base_convert(strval(ord($l[$i])),10,2),8,'0',STR_PAD_LEFT);
+ }
+ $c='';
+ foreach (str_split($b, 5) as $b) {
+ $c .= A[base_convert(str_pad($b, 5, '0'), 2, 10)];
+ }
+ $c .= match (strlen($b) % 40) {
+ 8 => '======',
+ 16 => '====',
+ 24 => '===',
+ 32 => '=',
+ default => '',
+ };
+ echo $c, "\n";
+}</code></pre> + <h2>実行結果</h2> + <div class="js-phper-token"> + </div> + <div class="mt-3"> + ステータス: <span class="js-aggregated-execution-status" data-answer-id="75">失敗</span> + </div> + <div class="mt-3"> + <h3>テストケース 1</h3> + <div> + ステータス: <span class="js-testcase-execution-status" data-testcase-execution-id="152">不正解</span> + </div> + <h4>標準出力</h4> + <pre><code class="js-testcase-execution-stdout hljs language-plaintext" data-testcase-execution-id="152"> +Warning: Uninitialized string offset 4 in php.wasm code on line 10 +N5TWKAA + +Warning: Uninitialized string offset 4 in php.wasm code on line 10 +NF4W6AA + +Warning: Uninitialized string offset 4 in php.wasm code on line 10 +OVTWCAA + +</code></pre> + <h4>標準エラー出力</h4> + <pre><code class="js-testcase-execution-stderr hljs language-plaintext" data-testcase-execution-id="152"> +</code></pre> + <h3>テストケース 2</h3> + <div> + ステータス: <span class="js-testcase-execution-status" data-testcase-execution-id="153">不正解</span> + </div> + <h4>標準出力</h4> + <pre><code class="js-testcase-execution-stdout hljs language-plaintext" data-testcase-execution-id="153"> +Warning: Uninitialized string offset 15 in php.wasm code on line 10 +QGDOHAML4OBIVY4BV7RYDEQA + +Warning: Uninitialized string offset 15 in php.wasm code on line 10 +QGVOHAMM4OBITY4BQ3RYDFYA + +Warning: Uninitialized string offset 15 in php.wasm code on line 10 +QKH6HAMZ4OBITY4CQLRYDIIA + +</code></pre> + <h4>標準エラー出力</h4> + <pre><code class="js-testcase-execution-stderr hljs language-plaintext" data-testcase-execution-id="153"> +</code></pre> + <h3>テストケース 3</h3> + <div> + ステータス: <span class="js-testcase-execution-status" data-testcase-execution-id="154">不正解</span> + </div> + <h4>標準出力</h4> + <pre><code class="js-testcase-execution-stdout hljs language-plaintext" data-testcase-execution-id="154"> +Warning: Uninitialized string offset 7 in php.wasm code on line 10 +GIZTINJWG4AA + +Warning: Uninitialized string offset 2 in php.wasm code on line 10 +GIAA + +Warning: Uninitialized string offset 10 in php.wasm code on line 10 +GIZTINJWG44DSMAA + +Warning: Uninitialized string offset 8 in php.wasm code on line 10 +GIZTINJWG44AA + +Warning: Uninitialized string offset 3 in php.wasm code on line 10 +GIZQA + +Warning: Uninitialized string offset 5 in php.wasm code on line 10 +GIZTINIA + +Warning: Uninitialized string offset 9 in php.wasm code on line 10 +GIZTINJWG44DSAA + +Warning: Uninitialized string offset 4 in php.wasm code on line 10 +GIZTIAA + +Warning: Uninitialized string offset 1 in php.wasm code on line 10 +AA + +Warning: Uninitialized string offset 6 in php.wasm code on line 10 +GIZTINJWAA + +</code></pre> + <h4>標準エラー出力</h4> + <pre><code class="js-testcase-execution-stderr hljs language-plaintext" data-testcase-execution-id="154"> +</code></pre> + <h3>テストケース 4</h3> + <div> + ステータス: <span class="js-testcase-execution-status" data-testcase-execution-id="155">不正解</span> + </div> + <h4>標準出力</h4> + <pre><code class="js-testcase-execution-stdout hljs language-plaintext" data-testcase-execution-id="155"> +Warning: Uninitialized string offset 5 in php.wasm code on line 10 +EBRCAYYA + +Warning: Uninitialized string offset 18 in php.wasm code on line 10 +QGBOHAMEEDRYDBRA4OAYQIHDQGFAA + +</code></pre> + <h4>標準エラー出力</h4> + <pre><code class="js-testcase-execution-stderr hljs language-plaintext" data-testcase-execution-id="155"> +</code></pre> + </div> + <script type="module" src="../../../../assets/loading.js"></script> + </main> + <footer class="container text-center mt-5 mb-4"> + Albatross.PHP - PHPerKaigi 2024 + </footer> + </body> +</html> |
