From fbd4f2129ce8fe106391302896dd86e05b2f331b Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 5 Dec 2025 04:08:22 +0900 Subject: add files --- archive/q/base32/a/94/index.html | 114 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 archive/q/base32/a/94/index.html (limited to 'archive/q/base32/a/94/index.html') diff --git a/archive/q/base32/a/94/index.html b/archive/q/base32/a/94/index.html new file mode 100644 index 0000000..cb16501 --- /dev/null +++ b/archive/q/base32/a/94/index.html @@ -0,0 +1,114 @@ + + + + + 問題 #2 - 回答 #94 | Albatross.PHP + + + + + +
+ +
+
+

問題 #2 - 回答 #94

+ + +

Base32

+

+ RFC 4648 で定義された Base32 エンコーディングを実装してください。 +標準入力から与えられる各行に対し、Base32 エンコードをおこなった文字列を標準出力へ改行区切りで出力してください。 +なお、アルファベットの出力には大文字を用いてください。 +

+

回答 #94

+

+ xpadev が 2024-03-08 21:36:57 に投稿 +

+

コード

+

+ 288 byte +

+
$a=array_merge(range('A','Z'),range(2,7));while ($b=base_convert(unpack('H*',rtrim(fgets(STDIN)))[1],16,2)) {$c=strlen($b);$b=str_split(str_pad($b,$c+(8-$c%8),'0',STR_PAD_LEFT),5);$e="";foreach($b as $d){$e.=$a[bindec(str_pad($d,5,"0"))];}$e.=str_repeat("=", 8-count($b)%8);echo $e."\n";}
+

実行結果

+
+
+
+ ステータス: 失敗 +
+
+

テストケース 1

+
+ ステータス: OK +
+

標準出力

+
NBXWOZI=
+OBUXS3Y=
+MZ2WOYI=
+
+
+

標準エラー出力

+

+
+

テストケース 2

+
+ ステータス: 不正解 +
+

標準出力

+
AAAAAAAAAAAAAAA=
+AAAAAAAAAAAAAAA=
+AAAAAAAAAAAAAAA=
+
+
+

標準エラー出力

+

+
+

テストケース 3

+
+ ステータス: 不正解 +
+

標準出力

+
GEZDGNBVGY4A====
+GEZA====
+AAZTINJWHAAAAAA=
+GEZDGNBVGY4AA===
+GEZDG===
+GEZDGNBV========
+AAZDGNBVGY4AAAA=
+GEZDGNA=
+GE======
+GEZDGNBVGY======
+
+
+

標準エラー出力

+

+
+

テストケース 4

+
+ ステータス: 不正解 +
+

標準出力

+
MEQGEIDD========
+AAAAAAAAAAAAAAA=
+
+
+

標準エラー出力

+

+
+
+ +
+ + + -- cgit v1.2.3-70-g09d2