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/109/index.html | 146 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 archive/q/base32/a/109/index.html (limited to 'archive/q/base32/a/109/index.html') diff --git a/archive/q/base32/a/109/index.html b/archive/q/base32/a/109/index.html new file mode 100644 index 0000000..40f764c --- /dev/null +++ b/archive/q/base32/a/109/index.html @@ -0,0 +1,146 @@ + + + + + 問題 #2 - 回答 #109 | Albatross.PHP + + + + + +
+ +
+
+

問題 #2 - 回答 #109

+ + +

Base32

+

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

+

回答 #109

+

+ hanhan1978 が 2024-03-09 01:34:27 に投稿 +

+

コード

+

+ 323 byte +

+
while($l=fgets(STDIN)){$l=rtrim($l);$z='';for(;$i<strlen($l);$i++){$z.=str_pad(base_convert(ord($l[$i]),10,2),8,'0',0);}$b3='';foreach(str_split($z,5) as $b){$b3.=str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZ234567')[base_convert(str_pad($b,5,'0'),2,10)];}echo $b3.=str_repeat('=',[8=>6,16=>4,24=>3,32=>1][strlen($z)%40]??0),"\n";}
+

実行結果

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

テストケース 1

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

標準出力

+

+Warning: Undefined variable $i in php.wasm code on line 6
+
+Warning: Undefined variable $i in php.wasm code on line 6
+
+Warning: String offset cast occurred in php.wasm code on line 6
+
+Warning: Undefined variable $i in php.wasm code on line 6
+NBXWOZI=
+
+
+
+
+

標準エラー出力

+

+
+

テストケース 2

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

標準出力

+

+Warning: Undefined variable $i in php.wasm code on line 6
+
+Warning: Undefined variable $i in php.wasm code on line 6
+
+Warning: String offset cast occurred in php.wasm code on line 6
+
+Warning: Undefined variable $i in php.wasm code on line 6
+4OAYNY4BRPRYFCXDQGX6HAMS
+
+
+
+
+

標準エラー出力

+

+
+

テストケース 3

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

標準出力

+

+Warning: Undefined variable $i in php.wasm code on line 6
+
+Warning: Undefined variable $i in php.wasm code on line 6
+
+Warning: String offset cast occurred in php.wasm code on line 6
+
+Warning: Undefined variable $i in php.wasm code on line 6
+GEZDGNBVGY3Q====
+
+HA4TA===
+
+
+
+
+
+
+
+
+
+

標準エラー出力

+

+
+

テストケース 4

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

標準出力

+

+Warning: Undefined variable $i in php.wasm code on line 6
+
+Warning: Undefined variable $i in php.wasm code on line 6
+
+Warning: String offset cast occurred in php.wasm code on line 6
+
+Warning: Undefined variable $i in php.wasm code on line 6
+MEQGEIDD
+4OAYIIHDQGDCBY4BRAQOHAMK
+
+
+

標準エラー出力

+

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