[SWEA] 7584 자가 복제 문자열

Time Lapse :35min 21sec

7584.c

1
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
#include <stdio.h>
//2020.02.17 기준 1등
int main(void){
register int test_case;
int T;
long long N;
scanf("%d",&T);
for(test_case = 1; test_case<=T; test_case++){
scanf("%lld",&N);
while(~N&1)
N>>=1;
printf("#%d %d\n",test_case, ~(~(N-1)>>1)&1);
}
return 0;
}
/* SAME CODE
#include <string>
#include <iostream>
using namespace std;
int main(void){
int test_case, T;
long long N;
scanf("%d",&T);
for(test_case = 1; test_case<=T; test_case++){
scanf("%lld",&N);
while((N%2)==0)
N>>=1;
if((N-1)/2%2==0)
printf("#%d 0\n",test_case);
else
printf("#%d 1\n",test_case);
}
return 0;
}
*/
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/08/04/PS/SWEA/7584/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.