Write a program to convert between a string and an array of 64-bit integers.
Note that the first character of the string should appear in the most significant bits of the the first element of the array.
Also note that you need to place the trailing '\0' into the integer, as shown in the following figure.
Every character has 8 bits, so we put 8 consecutive characters into a 64-bit integer starting from the most significant byte (MSB).
You may need more than one integer for storing a long string.
If the characters do not fill the entire 64 bits, you should set the remaining bits to 0.
The following is an example showing the extra 0 bits.
string to integer array
You also have to do the reverse.
That is, given an array of 64-bit integers, you have to generate a string by extracting each byte of the 64-bit integers.
The string ends when you have a byte of 0, which is also the character ‘\0’.
integer array to string
Note that you have to use long long variables to store 64-bit integers, and use “%lld” in scanf() and printf().
We also suggest that you use scanf(“%s”) to read the input string.
The first line has an integer task type $T$.
If $T$ is 0 then you convert a string into an integer array.
If $T$ is 1 then you convert an integer array into a string.
If $T$ is 0 the second line is a string $S$.
If $T$ is 1 the second line has the size of the array size $N$, and the each of the following $N$ lines has one 64-bit integer for the array.
Note that the characters we use in this task are all printable ASCII code and wihtout space.
$0 \lt length\ of\ S \lt 100000$
$0 \lt N \lt 12500$
If $T$ is 0 the output is the array of 64-bit integers, with one line containing one integer.
If $T$ is 1 the output is a string.
10 points: $T$ is 0 and $S$ has exactly 7 characters (not including the ending ‘\0’).
40 points: $T$ is 0 and $S$ is not necessarily 7.
10 points: $T$ is 1, the size of the integer array is 1, and only the least significant byte of that integer is 0.
That is, the string has exactly 7 characters.
40 points: $T$ is 1, and there are arbitrary number of characters.