結果
問題 | No.3005 天使のハッシュ関数 |
ユーザー | tatt61880 |
提出日時 | 2021-04-10 03:21:31 |
言語 | Kuin (KuinC++ v.2021.9.17) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,416 bytes |
コンパイル時間 | 3,341 ms |
コンパイル使用メモリ | 155,568 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-16 12:29:56 |
合計ジャッジ時間 | 3,290 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
ソースコード
func main() var s: []char :: cui@input() if(s =& null) do s :: "" end if do s :: @md5(s) do cui@print("\{s}\n") end func func md5(message: []char): []char var input: []bit8 :: #[^message]bit8 for i(0, ^message - 1) do input[i] :: message[i] $ bit8 end for ret @md5Sub(input) end func func md5Sub(message: []bit8): []char func leftRotate(x: bit32, c: int): bit32 ret x.shl(c).or(x.shr(32 - c)) end func var s: []int :: [ |7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, |5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, |4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, |6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21 |] var k: []bit64 :: [ |0xD76AA478b64, 0xE8C7B756b64, 0x242070DBb64, 0xC1BDCEEEb64, |0xF57C0FAFb64, 0x4787C62Ab64, 0xA8304613b64, 0xFD469501b64, |0x698098D8b64, 0x8B44F7AFb64, 0xFFFF5BB1b64, 0x895CD7BEb64, |0x6B901122b64, 0xFD987193b64, 0xA679438Eb64, 0x49B40821b64, |0xF61E2562b64, 0xC040B340b64, 0x265E5A51b64, 0xE9B6C7AAb64, |0xD62F105Db64, 0x02441453b64, 0xD8A1E681b64, 0xE7D3FBC8b64, |0x21E1CDE6b64, 0xC33707D6b64, 0xF4D50D87b64, 0x455A14EDb64, |0xA9E3E905b64, 0xFCEFA3F8b64, 0x676F02D9b64, 0x8D2A4C8Ab64, |0xFFFA3942b64, 0x8771F681b64, 0x6D9D6122b64, 0xFDE5380Cb64, |0xA4BEEA44b64, 0x4BDECFA9b64, 0xF6BB4B60b64, 0xBEBFBC70b64, |0x289B7EC6b64, 0xEAA127FAb64, 0xD4EF3085b64, 0x04881D05b64, |0xD9D4D039b64, 0xE6DB99E5b64, 0x1FA27CF8b64, 0xC4AC5665b64, |0xF4292244b64, 0x432AFF97b64, 0xAB9423A7b64, 0xFC93A039b64, |0x655B59C3b64, 0x8F0CCC92b64, 0xFFEFF47Db64, 0x85845DD1b64, |0x6FA87E4Fb64, 0xFE2CE6E0b64, 0xA3014314b64, 0x4E0811A1b64, |0xF7537E82b64, 0xBD3AF235b64, 0x2AD7D2BBb64, 0xEB86D391b64 |] var a0: bit32 :: 0x67452301b32 var b0: bit32 :: 0xEFCDAB89b32 var c0: bit32 :: 0x98BADCFEb32 var d0: bit32 :: 0x10325476b32 var initialMessageLength: int :: ^message * 8 do message :~ [0x80b8] while(^message % 64 <> 56) do message :~ [0b8] end while for i(0, 7) do message :~ [(initialMessageLength % 256) $ bit8] do initialMessageLength :/ 256 end for for ii(0, ^message / 64 - 1) var m: []bit32 :: #[16]bit32 for i(0, 15) for j(3, 0, -1) do m[i] :* 256b32 do m[i] :: message[ii * 64 + 4 * i + j] $ bit32 end for end for var a: bit32 :: a0 var b: bit32 :: b0 var c: bit32 :: c0 var d: bit32 :: d0 for i(0, 63) var f: bit32 var g: int switch(i) case 0 to 15 do f :: (b.and(c)).or(b.not().and(d)) do g :: i case 16 to 31 do f :: (d.and(b)).or(d.not().and(c)) do g :: (5 * i + 1) % 16 case 32 to 47 do f :: b.xor(c).xor(d) do g :: (3 * i + 5) % 16 case 48 to 63 do f :: c.xor(b.or(d.not())) do g :: (7 * i) % 16 end switch do f :+ a + k[i] $ bit32 + m[g] do a :: d do d :: c do c :: b do b :+ leftRotate(f, s[i]) end for do a0 :+ a do b0 :+ b do c0 :+ c do d0 :+ d end for var md5: []bit8 :: #[16]bit8 for i(0, 3) do md5[0 + i] :: a0.and(0xFFb32) $ bit8 do md5[4 + i] :: b0.and(0xFFb32) $ bit8 do md5[8 + i] :: c0.and(0xFFb32) $ bit8 do md5[12 + i] :: d0.and(0xFFb32) $ bit8 do a0 :: a0.shr(8) do b0 :: b0.shr(8) do c0 :: c0.shr(8) do d0 :: d0.shr(8) end for var res: []char :: #[32]char for i(0, 15) do res[2 * i] :: (md5[i].shr(4) $ int).toStrFmt("x")[0] do res[2 * i + 1] :: (md5[i].and(0x0Fb8) $ int).toStrFmt("x")[0] end for ret res end func