{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\nOne day, Nobita found that his computer is extremely slow. After several hours\u0027 work, he finally found that it was a virus that made his poor computer slow and the virus was activated by a misoperation of opening an attachment of an email.\n\u003c/p\u003e\n\u003cp\u003e\nNobita did use an outstanding anti-virus software, however, for some strange reason, this software did not check email attachments. Now Nobita decide to detect viruses in emails by himself.\n\u003c/p\u003e\n\u003cp\u003e\nTo detect an virus, a virus sample (several binary bytes) is needed. If these binary bytes can be found in the email attachment (binary data), then the attachment contains the virus.\n\u003c/p\u003e\n\u003cp\u003e\nNote that attachments (binary data) in emails are usually encoded in base64. To encode a binary stream in base64, first write the binary stream into bits. Then take 6 bits from the stream in turn, encode these 6 bits into a base64 character according the following table:\n\u003c/p\u003e\n\u003cp\u003e\nThat is, translate every 3 bytes into 4 base64 characters. If the original binary stream contains 3\u003cvar\u003ek\u003c/var\u003e + 1 bytes, where \u003cvar\u003ek\u003c/var\u003e is an integer, fill last bits using zero when encoding and append \u0027\u003d\u003d\u0027 as padding. If the original binary stream contains 3\u003cvar\u003ek\u003c/var\u003e + 2 bytes, fill last bits using zero when encoding and append \u0027\u003d\u0027 as padding. No padding is needed when the original binary stream contains 3\u003cvar\u003ek\u003c/var\u003e bytes.\n\u003c/p\u003e\n\u003cp\u003e\n\u003c/p\u003e\u003ctable class\u003d\"b64\"\u003e\n\u003ctbody\u003e\u003ctr\u003e\u003ctd\u003e\u003cb\u003eValue\u003c/b\u003e\u003c/td\u003e\u003ctd\u003e0\u003c/td\u003e\u003ctd\u003e1\u003c/td\u003e\u003ctd\u003e2\u003c/td\u003e\u003ctd\u003e3\u003c/td\u003e\u003ctd\u003e4\u003c/td\u003e\u003ctd\u003e5\u003c/td\u003e\u003ctd\u003e6\u003c/td\u003e\u003ctd\u003e7\u003c/td\u003e\u003ctd\u003e8\u003c/td\u003e\u003ctd\u003e9\u003c/td\u003e\u003ctd\u003e10\u003c/td\u003e\u003ctd\u003e11\u003c/td\u003e\u003ctd\u003e12\u003c/td\u003e\u003ctd\u003e13\u003c/td\u003e\u003ctd\u003e14\u003c/td\u003e\u003ctd\u003e15\u003c/td\u003e\u003ctd\u003e16\u003c/td\u003e\u003ctd\u003e17\u003c/td\u003e\u003ctd\u003e18\u003c/td\u003e\u003ctd\u003e19\u003c/td\u003e\u003ctd\u003e20\u003c/td\u003e\u003ctd\u003e21\u003c/td\u003e\u003ctd\u003e22\u003c/td\u003e\u003ctd\u003e23\u003c/td\u003e\u003ctd\u003e24\u003c/td\u003e\u003ctd\u003e25\u003c/td\u003e\u003ctd\u003e26\u003c/td\u003e\u003ctd\u003e27\u003c/td\u003e\u003ctd\u003e28\u003c/td\u003e\u003ctd\u003e29\u003c/td\u003e\u003ctd\u003e30\u003c/td\u003e\u003ctd\u003e31\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cb\u003eEncoding\u003c/b\u003e\u003c/td\u003e\u003ctd\u003eA\u003c/td\u003e\u003ctd\u003eB\u003c/td\u003e\u003ctd\u003eC\u003c/td\u003e\u003ctd\u003eD\u003c/td\u003e\u003ctd\u003eE\u003c/td\u003e\u003ctd\u003eF\u003c/td\u003e\u003ctd\u003eG\u003c/td\u003e\u003ctd\u003eH\u003c/td\u003e\u003ctd\u003eI\u003c/td\u003e\u003ctd\u003eJ\u003c/td\u003e\u003ctd\u003eK\u003c/td\u003e\u003ctd\u003eL\u003c/td\u003e\u003ctd\u003eM\u003c/td\u003e\u003ctd\u003eN\u003c/td\u003e\u003ctd\u003eO\u003c/td\u003e\u003ctd\u003eP\u003c/td\u003e\u003ctd\u003eQ\u003c/td\u003e\u003ctd\u003eR\u003c/td\u003e\u003ctd\u003eS\u003c/td\u003e\u003ctd\u003eT\u003c/td\u003e\u003ctd\u003eU\u003c/td\u003e\u003ctd\u003eV\u003c/td\u003e\u003ctd\u003eW\u003c/td\u003e\u003ctd\u003eX\u003c/td\u003e\u003ctd\u003eY\u003c/td\u003e\u003ctd\u003eZ\u003c/td\u003e\u003ctd\u003ea\u003c/td\u003e\u003ctd\u003eb\u003c/td\u003e\u003ctd\u003ec\u003c/td\u003e\u003ctd\u003ed\u003c/td\u003e\u003ctd\u003ee\u003c/td\u003e\u003ctd\u003ef\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cb\u003eValue\u003c/b\u003e\u003c/td\u003e\u003ctd\u003e32\u003c/td\u003e\u003ctd\u003e33\u003c/td\u003e\u003ctd\u003e34\u003c/td\u003e\u003ctd\u003e35\u003c/td\u003e\u003ctd\u003e36\u003c/td\u003e\u003ctd\u003e37\u003c/td\u003e\u003ctd\u003e38\u003c/td\u003e\u003ctd\u003e39\u003c/td\u003e\u003ctd\u003e40\u003c/td\u003e\u003ctd\u003e41\u003c/td\u003e\u003ctd\u003e42\u003c/td\u003e\u003ctd\u003e43\u003c/td\u003e\u003ctd\u003e44\u003c/td\u003e\u003ctd\u003e45\u003c/td\u003e\u003ctd\u003e46\u003c/td\u003e\u003ctd\u003e47\u003c/td\u003e\u003ctd\u003e48\u003c/td\u003e\u003ctd\u003e49\u003c/td\u003e\u003ctd\u003e50\u003c/td\u003e\u003ctd\u003e51\u003c/td\u003e\u003ctd\u003e52\u003c/td\u003e\u003ctd\u003e53\u003c/td\u003e\u003ctd\u003e54\u003c/td\u003e\u003ctd\u003e55\u003c/td\u003e\u003ctd\u003e56\u003c/td\u003e\u003ctd\u003e57\u003c/td\u003e\u003ctd\u003e58\u003c/td\u003e\u003ctd\u003e59\u003c/td\u003e\u003ctd\u003e60\u003c/td\u003e\u003ctd\u003e61\u003c/td\u003e\u003ctd\u003e62\u003c/td\u003e\u003ctd\u003e63\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cb\u003eEncoding\u003c/b\u003e\u003c/td\u003e\u003ctd\u003eg\u003c/td\u003e\u003ctd\u003eh\u003c/td\u003e\u003ctd\u003ei\u003c/td\u003e\u003ctd\u003ej\u003c/td\u003e\u003ctd\u003ek\u003c/td\u003e\u003ctd\u003el\u003c/td\u003e\u003ctd\u003em\u003c/td\u003e\u003ctd\u003en\u003c/td\u003e\u003ctd\u003eo\u003c/td\u003e\u003ctd\u003ep\u003c/td\u003e\u003ctd\u003eq\u003c/td\u003e\u003ctd\u003er\u003c/td\u003e\u003ctd\u003es\u003c/td\u003e\u003ctd\u003et\u003c/td\u003e\u003ctd\u003eu\u003c/td\u003e\u003ctd\u003ev\u003c/td\u003e\u003ctd\u003ew\u003c/td\u003e\u003ctd\u003ex\u003c/td\u003e\u003ctd\u003ey\u003c/td\u003e\u003ctd\u003ez\u003c/td\u003e\u003ctd\u003e0\u003c/td\u003e\u003ctd\u003e1\u003c/td\u003e\u003ctd\u003e2\u003c/td\u003e\u003ctd\u003e3\u003c/td\u003e\u003ctd\u003e4\u003c/td\u003e\u003ctd\u003e5\u003c/td\u003e\u003ctd\u003e6\u003c/td\u003e\u003ctd\u003e7\u003c/td\u003e\u003ctd\u003e8\u003c/td\u003e\u003ctd\u003e9\u003c/td\u003e\u003ctd\u003e+\u003c/td\u003e\u003ctd\u003e/\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003e\nFor example, to encode \u0027hello\u0027 into base64, first write \u0027hello\u0027 as binary bits, that is: \n\u003cspan class\u003d\"code\"\u003e01101000 01100101 01101100 01101100 01101111\u003c/span\u003e\u003cbr\u003e\nThen, take 6 bits in turn and fill last bits as zero as padding (zero padding bits are marked in bold): \n\u003cspan class\u003d\"code\"\u003e011010 000110 010101 101100 011011 000110 1111\u003cb\u003e00\u003c/b\u003e\u003c/span\u003e\u003cbr\u003e\nThey are \n\u003cspan class\u003d\"code\"\u003e26 6 21 44 27 6 60\u003c/span\u003e\nin decimal. Look up the table above and use corresponding characters: \n\u003cspan class\u003d\"code\"\u003eaGVsbG8\u003c/span\u003e\u003cbr\u003e\nSince original binary data contains 1 * 3 + 2 bytes, padding is needed, append \u0027\u003d\u0027 and \u0027hello\u0027 is finally encoded in base64:\n\u003cspan class\u003d\"code\"\u003eaGVsbG8\u003d\u003c/span\u003e\n\u003c/p\u003e\n\u003cp\u003e\nSection 5.2 of RFC 1521 describes how to encode a binary stream in base64 much more detailedly:\n\u003c/p\u003e\n\u003cscript type\u003d\"text/javascript\"\u003e\nfunction show_id(id) {\n document.getElementById(id).style.display\u003d\"block\";\n}\nfunction hide_id(id) {\n document.getElementById(id).style.display\u003d\"none\";\n}\n\u003c/script\u003e\n\u003ca class\u003d\"expander\" onclick\u003d\"show_id(\u0027rfc_long\u0027); hide_id(\u0027rfc_long_toggle\u0027); return false;\" href\u003d\"\" id\u003d\"rfc_long_toggle\"\u003eClick here to see Section 5.2 of RFC 1521 if you have interest\u003c/a\u003e\n\u003cpre style\u003d\"height:400px; overflow:auto; background:#eee; display:none;\" id\u003d\"rfc_long\"\u003eThe Base64 Content-Transfer-Encoding is designed to represent\narbitrary sequences of octets in a form that need not be humanly\nreadable. The encoding and decoding algorithms are simple, but the\nencoded data are consistently only about 33 percent larger than the\nunencoded data. This encoding is virtually identical to the one used\nin Privacy Enhanced Mail (PEM) applications, as defined in RFC 1421.\nThe base64 encoding is adapted from RFC 1421, with one change: base64\neliminates the \"*\" mechanism for embedded clear text.\n\nA 65-character subset of US-ASCII is used, enabling 6 bits to be\nrepresented per printable character. (The extra 65th character, \"\u003d\",\nis used to signify a special processing function.)\n\n NOTE: This subset has the important property that it is\n represented identically in all versions of ISO 646, including US\n ASCII, and all characters in the subset are also represented\n identically in all versions of EBCDIC. Other popular encodings,\n such as the encoding used by the uuencode utility and the base85\n encoding specified as part of Level 2 PostScript, do not share\n these properties, and thus do not fulfill the portability\n requirements a binary transport encoding for mail must meet.\n\nThe encoding process represents 24-bit groups of input bits as output\nstrings of 4 encoded characters. Proceeding from left to right, a\n24-bit input group is formed by concatenating 3 8-bit input groups.\nThese 24 bits are then treated as 4 concatenated 6-bit groups, each\nof which is translated into a single digit in the base64 alphabet.\nWhen encoding a bit stream via the base64 encoding, the bit stream\nmust be presumed to be ordered with the most-significant-bit first.\n\nThat is, the first bit in the stream will be the high-order bit in\nthe first byte, and the eighth bit will be the low-order bit in the\nfirst byte, and so on.\n\nEach 6-bit group is used as an index into an array of 64 printable\ncharacters. The character referenced by the index is placed in the\noutput string. These characters, identified in Table 1, below, are\nselected so as to be universally representable, and the set excludes\ncharacters with particular significance to SMTP (e.g., \".\", CR, LF)\nand to the encapsulation boundaries defined in this document (e.g.,\n\"-\").\n\nTable 1: The Base64 Alphabet\n\n Value Encoding Value Encoding Value Encoding Value Encoding\n 0 A 17 R 34 i 51 z\n 1 B 18 S 35 j 52 0\n 2 C 19 T 36 k 53 1\n 3 D 20 U 37 l 54 2\n 4 E 21 V 38 m 55 3\n 5 F 22 W 39 n 56 4\n 6 G 23 X 40 o 57 5\n 7 H 24 Y 41 p 58 6\n 8 I 25 Z 42 q 59 7\n 9 J 26 a 43 r 60 8\n10 K 27 b 44 s 61 9\n11 L 28 c 45 t 62 +\n12 M 29 d 46 u 63 /\n13 N 30 e 47 v\n14 O 31 f 48 w (pad) \u003d\n15 P 32 g 49 x\n16 Q 33 h 50 y\n\nThe output stream (encoded bytes) must be represented in lines of no\nmore than 76 characters each. All line breaks or other characters\nnot found in Table 1 must be ignored by decoding software. In base64\ndata, characters other than those in Table 1, line breaks, and other\nwhite space probably indicate a transmission error, about which a\nwarning message or even a message rejection might be appropriate\nunder some circumstances.\n\nSpecial processing is performed if fewer than 24 bits are available\nat the end of the data being encoded. A full encoding quantum is\nalways completed at the end of a body. When fewer than 24 input bits\nare available in an input group, zero bits are added (on the right)\nto form an integral number of 6-bit groups. Padding at the end of\nthe data is performed using the \u0027\u003d\u0027 character. Since all base64\ninput is an integral number of octets, only the following cases can\narise: (1) the final quantum of encoding input is an integral\nmultiple of 24 bits; here, the final unit of encoded output will be\nan integral multiple of 4 characters with no \"\u003d\" padding, (2) the\nfinal quantum of encoding input is exactly 8 bits; here, the final\nunit of encoded output will be two characters followed by two \"\u003d\"\npadding characters, or (3) the final quantum of encoding input is\nexactly 16 bits; here, the final unit of encoded output will be three\ncharacters followed by one \"\u003d\" padding character.\n\nBecause it is used only for padding at the end of the data, the\noccurrence of any \u0027\u003d\u0027 characters may be taken as evidence that the\nend of the data has been reached (without truncation in transit). No\nsuch assurance is possible, however, when the number of octets\ntransmitted was a multiple of three.\n\nAny characters outside of the base64 alphabet are to be ignored in\nbase64-encoded data. The same applies to any illegal sequence of\ncharacters in the base64 encoding, such as \"\u003d\u003d\u003d\u003d\u003d\"\n\nCare must be taken to use the proper octets for line breaks if base64\nencoding is applied directly to text material that has not been\nconverted to canonical form. In particular, text line breaks must be\nconverted into CRLF sequences prior to base64 encoding. The important\nthing to note is that this may be done directly by the encoder rather\nthan in a prior canonicalization step in some implementations.\n\n NOTE: There is no need to worry about quoting apparent\n encapsulation boundaries within base64-encoded parts of multipart\n entities because no hyphen characters are used in the base64\n encoding.\n\u003c/pre\u003e\n\u003cp\u003eHere is a piece of ANSI C code that can encode binary data in base64. It contains a function, \u003cem\u003eencode (infile, outfile)\u003c/em\u003e, to encode binary file \u003cem\u003einfile\u003c/em\u003e in base64 and output result to \u003cem\u003eoutfile\u003c/em\u003e.\u003c/p\u003e\n\u003ca class\u003d\"expander\" onclick\u003d\"show_id(\u0027code\u0027); hide_id(\u0027code_toggle\u0027); return false;\" href\u003d\"\" id\u003d\"code_toggle\"\u003eClick here to see the reference C code if you have interest\u003c/a\u003e\n\u003cdiv id\u003d\"code\" style\u003d\"background:#eee; color:black; display:none;\"\u003e\u003cfont face\u003d\"monospace\"\u003e\n\u003cfont color\u003d\"#a020f0\"\u003e#include \u003c/font\u003e\u003cfont color\u003d\"#ff00ff\"\u003e\u0026lt;stdio.h\u0026gt;\u003c/font\u003e\u003cbr\u003e\n\u003cbr\u003e\n\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003estatic\u003c/b\u003e\u003c/font\u003e\u0026nbsp;\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003econst\u003c/b\u003e\u003c/font\u003e\u0026nbsp;\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003echar\u003c/b\u003e\u003c/font\u003e\u0026nbsp;cb64[]\u0026nbsp;\u003d\u0026nbsp;\u003cfont color\u003d\"#ff00ff\"\u003e\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\"\u003c/font\u003e;\u003cbr\u003e\n\u003cbr\u003e\n\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003evoid\u003c/b\u003e\u003c/font\u003e\u0026nbsp;encodeblock(\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003eunsigned\u003c/b\u003e\u003c/font\u003e\u0026nbsp;\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003echar\u003c/b\u003e\u003c/font\u003e\u0026nbsp;in[\u003cfont color\u003d\"#ff00ff\"\u003e3\u003c/font\u003e], \u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003eunsigned\u003c/b\u003e\u003c/font\u003e\u0026nbsp;\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003echar\u003c/b\u003e\u003c/font\u003e\u0026nbsp;out[\u003cfont color\u003d\"#ff00ff\"\u003e4\u003c/font\u003e], \u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003eint\u003c/b\u003e\u003c/font\u003e\u0026nbsp;len) {\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;out[\u003cfont color\u003d\"#ff00ff\"\u003e0\u003c/font\u003e] \u003d cb64[ in[\u003cfont color\u003d\"#ff00ff\"\u003e0\u003c/font\u003e] \u0026gt;\u0026gt; \u003cfont color\u003d\"#ff00ff\"\u003e2\u003c/font\u003e\u0026nbsp;];\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;out[\u003cfont color\u003d\"#ff00ff\"\u003e1\u003c/font\u003e] \u003d cb64[ ((in[\u003cfont color\u003d\"#ff00ff\"\u003e0\u003c/font\u003e] \u0026amp; \u003cfont color\u003d\"#ff00ff\"\u003e0x03\u003c/font\u003e) \u0026lt;\u0026lt; \u003cfont color\u003d\"#ff00ff\"\u003e4\u003c/font\u003e) | ((in[\u003cfont color\u003d\"#ff00ff\"\u003e1\u003c/font\u003e] \u0026amp; \u003cfont color\u003d\"#ff00ff\"\u003e0xf0\u003c/font\u003e) \u0026gt;\u0026gt; \u003cfont color\u003d\"#ff00ff\"\u003e4\u003c/font\u003e) ];\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;out[\u003cfont color\u003d\"#ff00ff\"\u003e2\u003c/font\u003e] \u003d (\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003eunsigned\u003c/b\u003e\u003c/font\u003e\u0026nbsp;\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003echar\u003c/b\u003e\u003c/font\u003e) (len \u0026gt; \u003cfont color\u003d\"#ff00ff\"\u003e1\u003c/font\u003e\u0026nbsp;? cb64[ ((in[\u003cfont color\u003d\"#ff00ff\"\u003e1\u003c/font\u003e] \u0026amp; \u003cfont color\u003d\"#ff00ff\"\u003e0x0f\u003c/font\u003e) \u0026lt;\u0026lt; \u003cfont color\u003d\"#ff00ff\"\u003e2\u003c/font\u003e) | ((in[\u003cfont color\u003d\"#ff00ff\"\u003e2\u003c/font\u003e] \u0026amp; \u003cfont color\u003d\"#ff00ff\"\u003e0xc0\u003c/font\u003e) \u0026gt;\u0026gt; \u003cfont color\u003d\"#ff00ff\"\u003e6\u003c/font\u003e) ] : \u003cfont color\u003d\"#ff00ff\"\u003e\u0027\u003d\u0027\u003c/font\u003e);\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;out[\u003cfont color\u003d\"#ff00ff\"\u003e3\u003c/font\u003e] \u003d (\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003eunsigned\u003c/b\u003e\u003c/font\u003e\u0026nbsp;\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003echar\u003c/b\u003e\u003c/font\u003e) (len \u0026gt; \u003cfont color\u003d\"#ff00ff\"\u003e2\u003c/font\u003e\u0026nbsp;? cb64[ in[\u003cfont color\u003d\"#ff00ff\"\u003e2\u003c/font\u003e] \u0026amp; \u003cfont color\u003d\"#ff00ff\"\u003e0x3f\u003c/font\u003e\u0026nbsp;] : \u003cfont color\u003d\"#ff00ff\"\u003e\u0027\u003d\u0027\u003c/font\u003e);\u003cbr\u003e\n}\u003cbr\u003e\n\u003cbr\u003e\n\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003evoid\u003c/b\u003e\u003c/font\u003e\u0026nbsp;encode(\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003eFILE\u003c/b\u003e\u003c/font\u003e\u0026nbsp;*infile, \u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003eFILE\u003c/b\u003e\u003c/font\u003e\u0026nbsp;*outfile)\u0026nbsp;{\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003eunsigned\u003c/b\u003e\u003c/font\u003e\u0026nbsp;\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003echar\u003c/b\u003e\u003c/font\u003e\u0026nbsp;in[\u003cfont color\u003d\"#ff00ff\"\u003e3\u003c/font\u003e], out[\u003cfont color\u003d\"#ff00ff\"\u003e4\u003c/font\u003e];\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003eint\u003c/b\u003e\u003c/font\u003e\u0026nbsp;i, len;\u003cbr\u003e\n\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003cfont color\u003d\"#a52a2a\"\u003e\u003cb\u003ewhile\u003c/b\u003e\u003c/font\u003e\u0026nbsp;(!feof(infile)) {\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;len \u003d \u003cfont color\u003d\"#ff00ff\"\u003e0\u003c/font\u003e;\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003cfont color\u003d\"#a52a2a\"\u003e\u003cb\u003efor\u003c/b\u003e\u003c/font\u003e\u0026nbsp;(i \u003d \u003cfont color\u003d\"#ff00ff\"\u003e0\u003c/font\u003e; i \u0026lt; \u003cfont color\u003d\"#ff00ff\"\u003e3\u003c/font\u003e; i++) {\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;in[i] \u003d (\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003eunsigned\u003c/b\u003e\u003c/font\u003e\u0026nbsp;\u003cfont color\u003d\"#2e8b57\"\u003e\u003cb\u003echar\u003c/b\u003e\u003c/font\u003e) getc(infile);\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003cfont color\u003d\"#a52a2a\"\u003e\u003cb\u003eif\u003c/b\u003e\u003c/font\u003e\u0026nbsp;(!feof(infile)) {\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;len++;\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;} \u003cfont color\u003d\"#a52a2a\"\u003e\u003cb\u003eelse\u003c/b\u003e\u003c/font\u003e\u0026nbsp;{\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;in[i] \u003d \u003cfont color\u003d\"#ff00ff\"\u003e0\u003c/font\u003e;\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;}\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;}\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003cfont color\u003d\"#a52a2a\"\u003e\u003cb\u003eif\u003c/b\u003e\u003c/font\u003e\u0026nbsp;(len) {\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;encodeblock(in, out, len);\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003cfont color\u003d\"#a52a2a\"\u003e\u003cb\u003efor\u003c/b\u003e\u003c/font\u003e\u0026nbsp;(i \u003d \u003cfont color\u003d\"#ff00ff\"\u003e0\u003c/font\u003e; i \u0026lt; \u003cfont color\u003d\"#ff00ff\"\u003e4\u003c/font\u003e; i++) {\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;putc(out[i], outfile);\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;}\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;}\u003cbr\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;}\u003cbr\u003e\n}\u003c/font\u003e\u003c/div\u003e\n\n\u003ch4\u003eInput\u003c/h4\u003e\n\u003cp\u003eInput contains multiple cases (about 15, of which most are small ones). The first line of each case contains an integer \u003cvar\u003eN\u003c/var\u003e (0 \u0026lt;\u003d \u003cvar\u003eN\u003c/var\u003e \u0026lt;\u003d 512). In the next \u003cvar\u003eN\u003c/var\u003e distinct lines, each line contains a sample of a kind of virus, which is not empty, has not more than 64 bytes in binary and is encoded in base64. Then, the next line contains an integer \u003cvar\u003eM\u003c/var\u003e (1 \u0026lt;\u003d \u003cvar\u003eM\u003c/var\u003e \u0026lt;\u003d 128). In the following \u003cvar\u003eM\u003c/var\u003e lines, each line contains the content of a file to be detected, which is not empty, has no more than 2048 bytes in binary and is encoded in base64.\u003c/p\u003e\n\u003cp\u003eThere is a blank line after each case.\u003c/p\u003e\n\n\u003ch4\u003eOutput\u003c/h4\u003e\n\u003cp\u003eFor each case, output \u003cvar\u003eM\u003c/var\u003e lines. The \u003cvar\u003ei\u003c/var\u003e\u003csup\u003eth\u003c/sup\u003e line contains the number of kinds of virus detected in the \u003cvar\u003ei\u003c/var\u003e\u003csup\u003eth\u003c/sup\u003e file.\u003c/p\u003e\n\u003cp\u003eOutput a blank line after each case.\u003c/p\u003e\n\n\u003ch4\u003eSample\u003c/h4\u003e\n\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\nYmFzZTY0\ndmlydXM\u003d\ndDog\n1\ndGVzdDogdmlydXMu\n\n1\nQA\u003d\u003d\n2\nQA\u003d\u003d\nICAgICAgICA\u003d\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n\n1\n0\n\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\n\u003ch4\u003eHint\u003c/h4\u003e\n\u003cp\u003eIn the first sample case, there are three virus samples: \u003cspan class\u003d\"code\"\u003ebase64\u003c/span\u003e, \u003cspan class\u003d\"code\"\u003evirus\u003c/span\u003e and \u003cspan class\u003d\"code\"\u003et: \u003c/span\u003e, the data to be checked is \u003cspan class\u003d\"code\"\u003etest: virus.\u003c/span\u003e, which contains the second and the third, two virus samples.\u003c/p\u003e\n\n"}}]}