50135. String and Integer
難度:3.8/51
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <string.h>
#include <stdint.h>
uint64_t pow_func(uint64_t b, int r){
uint64_t ans = 1;
while(r--) ans *= b;
return ans;
}
void solve_0(){
int cnt = 0;
uint64_t ans = 0;
uint8_t c;
while(scanf("%c", &c) != EOF && c != '\n'){
ans = ans * (uint64_t)256 + (uint64_t)c;
cnt++;
if(cnt == 8){
printf("%llu\n", ans);
ans = 0;
cnt = 0;
}
}
while(cnt != 8){
ans *= (uint64_t)256;
cnt++;
}
printf("%llu\n", ans);
}
void solve_1(){
int n; scanf("%d", &n);
for(int i = 0; i < n; i++){
uint64_t ans; scanf("%llu", &ans);
for(int j = 7; j >= 0; j--){
uint8_t c = (uint8_t)(ans >> (8 * j));
if(c != 0) printf("%c", c);
}
}
}
int main(){
int task; scanf("%d", &task); getchar();
if(task == 0) solve_0();
else solve_1();
}