prob_desc_description
stringlengths
63
3.8k
prob_desc_output_spec
stringlengths
17
1.47k
lang_cluster
stringclasses
2 values
src_uid
stringlengths
32
32
code_uid
stringlengths
32
32
lang
stringclasses
7 values
prob_desc_output_to
stringclasses
3 values
prob_desc_memory_limit
stringclasses
19 values
file_name
stringclasses
111 values
tags
listlengths
0
11
prob_desc_created_at
stringlengths
10
10
prob_desc_sample_inputs
stringlengths
2
802
prob_desc_notes
stringlengths
4
3k
exec_outcome
stringclasses
1 value
difficulty
int64
-1
3.5k
prob_desc_input_from
stringclasses
3 values
prob_desc_time_limit
stringclasses
27 values
prob_desc_input_spec
stringlengths
28
2.42k
prob_desc_sample_outputs
stringlengths
2
796
source_code
stringlengths
42
65.5k
hidden_unit_tests
stringclasses
1 value
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
de6a16b867cca7114c7c7d12d8bb4012
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include <stdio.h> int cal(int x) { int m=0; while (x!=1){ if(x%6==0) { x=x/6; } else { x=x*2; if(x%6!=0) { return -1; break; } } m=m+1; } return m; } int main() { int n,n1; scanf(...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
0a1d177e337f734c9b2e45cacf3485de
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include <stdio.h> int main(void) { int rep; scanf("%d", &rep); int i; for (i = 0; i < rep; i++) { int x, num_2 = 0, num_3 = 0; scanf("%d", &x); while (x % 2 == 0) { x /= 2; num_2++; } while (x % 3 == 0) { ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
deeca6a6b023b2f2444201b6cfaf6f9c
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include<stdio.h> int main() { int a,b,c[20000],d,e,f; scanf("%d",&a); b=1; while(b<=a) { scanf("%d",&c[b]); b=b+1; } d=1; while(d<=a) {f=0; if(c[d]==1) { printf("0\n"); } if(c[d]!=1) { e=c[d]; while(e>1) { if(e%6==0) { e=e/6;f=f+1; } else if(e%3==0) {e=e*2; ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
9156af103c96e1579d1392df8cba3dba
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include<stdio.h> int main(){ long long int a,n,c,i; scanf("%lld",&a); for(i=1;i<=a;i++){ scanf("%lld",&n); c=0; while(1){ if(n%6==0){ n=n/6; c++; } else if((n*2)%6==0){ n=n*2; c++; ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
74c9dd90099df46761889bbc29355825
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include <stdio.h> int main() { short t; long long n, tab[20000]; scanf("%hd", &t); for (short i = 0; i < t; ++i) { scanf("%lld", &n); tab[i] = 0; int counter = 0; while(n > 5 && counter < 2) { if (n % 6 == 0) { n /= 6; ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
25892d6746d12acdcafe7bfb01c2735a
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include <stdio.h> int t, n; int main() { scanf("%d", &t); for(int i = 0; i < t; i++) { scanf("%d", &n); int count = 0; int i = n; while(1) { if(i == 1) { break; } if((i % 2 == 0) && (i % 6 != 0)){ ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
3c968a8e8419b3add3ed4034ec23865a
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include<stdio.h> int main() { int t; scanf("%d",&t); while(t--) { long long int n,i; scanf("%lli",&n); if(n==1) { printf("%d\n",0); } else if(n<3 || n%3!=0) { printf("%d\n",-1); } else { f...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
ae0f49844f5076fd9ae97928ef89485b
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include <stdio.h> int main(){ long int i; scanf("%ld", &i); for(int j = i; j != 0; j--){ long long int n, count = 0; scanf("%lld", &n); while(n != 1){ if(n % 3 != 0){ count = -1; break; } else{ if(n % 6 == 0){ n /= 6; } else { n *= 2; } count++; } } print...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
c19df65a42831d83c25e9eff81bd3dda
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include"stdio.h" int main() { long n,t; scanf("%d",&t); while(t--){ scanf("%d",&n); long x=0; while(n!=0) { if(n%3&&n%6!=0) break; if(n==1) break; if(n%6==0) { n/=6; x++; } else if(n%3==0) { n/=3; x+=2; } } if(n==1) printf("%ld\n",x); else printf("-1\n"); } return 0; }
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
979ed98474859fc353b8266d2e0d0e9d
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include <stdio.h> int main(){ int t; scanf("%d",&t); int i,sayilar[t],islemler[t]; for(i=0;i<t;i++){ scanf("%d",&sayilar[i]); } for(i=0;i<t;i++){ islemler[i]=0; } int j; for(i=0;i<t;i++){ for(j=0;;j++){ if(sayilar[i]%6==0){ islemler[i]+=1; sayilar[i]/=6; }else if(sayilar[i]%3==0){ islemle...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
eee2db4f98290ab7ad09a5193d18eb54
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include<stdio.h> int main() { int t,n,count=0; scanf("%d", &t); while(t--) { count=0; scanf("%d", &n); while(n>=3) { while(n%6==0) { n=n/6; count++; } if(n==1) { ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
a3a59b224639a99631c855fa8c78781a
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include <stdio.h> int main() { int t; scanf("%d",&t); int n,i,c; for(i = 0; i < t; i++){ scanf("%d",&n); c= 0; while(n % 6 == 0) { n/= 6; c++; } while(n % 3 == 0) { n/= 3; c+= 2; } if(n==1) printf("%...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
5fd9f5b58f4a9e1e63b47c4e86058b41
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include<stdio.h> int main(void){ int i,j,k=1,n,t; scanf("%d",&t); for(i=0;i<t;i++){ scanf("%d",&n); k=0; for(;;){ if(n==1){ printf("%d\n",k); break; } else if(n%6==0){ n=n/6; k++; ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
e0f1287d2484d3bb53ead52697c92e0d
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include<stdio.h> int main() { int t,n,count; scanf("%d",&t); for(int i=0;i<t;i++) { count=0; scanf("%d",&n); if(n==1) printf("0\n"); while(n!=1) { if(n%3!=0 && n!=1) { printf("-1\n"); n=1; ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
95b369d3a46d5aa1b64dbda339eb117f
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include <stdio.h> #include <stdlib.h> int main(void) { int num=0,i; long unsigned n; scanf("%lu", &n); for(;n>0;n--){ scanf("%d", &i); if(i==1) printf("0\n"); else if(i%3) printf("-1\n"); else{ while(i!=1){ for(;;){ if(...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
d9ab85c17173916dee7c2c38c23d13a7
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include<stdio.h> int main() { int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int x=0; while(n!=1) { if(n%6==0) { n=n/6; x++; } else { if((n*2)%...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
61691f341a0114583bb8caace41b4fe4
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include<stdio.h> int main(){ int n,a,s; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&a); s=0; while(a!=1){ while(a%3==0){ if(a%6==0){ a=a/6; s++; continue; } else{ a=a/3; s+=2; continue; } } if(a%3!=0&&a!=1){ printf("-1\n"); bre...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
0e55a4c5ebe13e6ec08e361a4f560e95
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include <stdio.h> int main(){ int t; scanf("%d",&t); while(t--){ int n; scanf("%d",&n); int count=0; while(n!=1){ if(n%6==0){ count++; n=n/6; }else if((n*2)%6==0){ n=n*2; count++; ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
b38afa37f4d137b83c02ed39ad5831b6
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include<stdio.h> int main() { int t,n; scanf("%d",&t); while(t--) {scanf("%d",&n); int c2=0,c3=0; while(n%2==0) { n=n/2; ++c2; } while(n%3==0) { n=n/3; ++c3; } if(n==1 &&c3>=c2) printf("%d",2*c3-c2); else printf("-1"); ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
8bbcdf6f4b87c7f4fa829cd511bbbcb5
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include<stdio.h> int main() { int t; scanf("%d",&t); while(t--) { int n,t=0,count=0; scanf("%d",&n); while(n>1) { if(n%6==0) { n/=6; t=0; } else if(t==0) { n*=2; ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
abe07e629f61b9a1274751e37251e684
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include<stdio.h> int main() { int t; scanf("%d",&t); while(t--) { int n,t=0,count=0; scanf("%d",&n); while(n>1) { if(n%6==0) { n/=6; t=0; } else if(t==0) { n*=2; ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
c0f48248911bb5efb72c6049d5bbc415
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include<stdio.h> int main() { int x,i; scanf("%d",&x); for(i=0;i<x;i++) { long long int n,count=0; scanf("%lld",&n); while(n!=1) { if(n%3==0) { if(n%2==0) { n=n/6; count++; ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
7854f48b5a2a569a161a902bfcff0b65
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include <stdio.h> int main(){ int a; scanf("%d",&a); for(int i=1;i<=a;i++){ long long int b; int c=0; int e=1; scanf("%lld",&b); while(b!=1){ if(b%6==0){ b/=6; c++; } else if(b%3==0){ b=b*2; c++; } else{ e=0; break; } } if(e==0){...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
ed6a01a8a9b0cf8bdb7272aba4ab71b8
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
/****************************************************************************** Online C Compiler. Code, Compile, Run and Debug C program online. Write your code in this editor and press "Run" button to compile and execute it. ***********************************************...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
c0e61e0462ffb9ca1136de447d155758
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include <stdio.h> int main(){ int t,n,i; scanf("%d",&t); for(i=0;i<t;i++){ int c=0; scanf("%d",&n); while(n>1){ if(n%6==0){ n=n/6; } else if(n%3==0){ n=n*2; } else{ break; ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
ab453e61d759622613aa36c82d2166eb
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include <stdio.h> int main() { int t,n; scanf("%d",&t); while(t--) { int count=0; scanf("%d",&n); while(n!=1) { if(n%3==0) { if(n%2==0) { count++; n=n/6; } ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
b937fbb2b9a1e68d1506a4f05a120e9a
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include <stdio.h> static inline unsigned long num_iterations(unsigned long num){ int i = 0; while (num > 1) { if (num % 3 != 0) { return -1; } else if (num % 6 != 0) { num *= 2; } else { num /= 6; } i++; } return i; } ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
d9bbf1bc0228d4fea1dd7a7dea581197
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include <stdio.h> static inline unsigned long num_iterations(unsigned long num){ int i = 0; int res; while (num > 1) { if ((res = num % 6) != 0) { if (res % 3 != 0){ return -1; } num *= 2; } else { num /= 6; } ...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
522a12bf1662d7c79e3fe8f27f27dcf1
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include <stdio.h> #include <stdlib.h> //#define local int main() { //#ifdef local //freopen("in.txt", "r", stdin); //#endif //freopen("out.txt", "w", stdout); int n; int step; scanf("%d", &n); while (n--) { int num = 0; scanf("%d", &num); for (step = 0;; step++) { if (num == 1) { printf("%d\n", s...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
0e1ffed3a9d7de9c0bab3a9aea3321b3
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include<stdio.h> int main() { int t,i,n,count,num; scanf("%d",&t); for(i=0;i<t;i++) { scanf("%d",&n); count = 0; num = n; while(num!=1) { if(num % 6 == 0) { num/=6; count++; } else if...
You are given an integer $$$n$$$. In one move, you can either multiply $$$n$$$ by two or divide $$$n$$$ by $$$6$$$ (if it is divisible by $$$6$$$ without the remainder).Your task is to find the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ or determine if it's impossible to do that.You have to answer $$...
For each test case, print the answer — the minimum number of moves needed to obtain $$$1$$$ from $$$n$$$ if it's possible to do that or -1 if it's impossible to obtain $$$1$$$ from $$$n$$$.
C
3ae468c425c7b156983414372fd35ab8
38246dd333b27f5a3aaf04a9d36e0cde
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "math" ]
1593354900
["7\n1\n2\n3\n12\n12345\n15116544\n387420489"]
NoteConsider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $$$15116544$$$: Divide by $$$6$$$ and get $$$2519424$$$; divide by $$$6$$$ and get $$$419904$$$; divide by $$$6$$$ and get $$$69984$$$; divide by $$$6$$$ and get $$$11664$$$; multip...
PASSED
900
standard input
1 second
The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).
["0\n-1\n2\n-1\n-1\n12\n36"]
#include<stdio.h> int main() { long long int test,n,i; scanf("%lld",&test); while(test--) { scanf("%lld",&n); i=0; while(n>1) { i++; if(n%6==0) n=n/6; else n=n*2; } if(n==1) p...
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments. He chose a number k such that gcd(n, k) = 1. Vertices of the polygon are numbered from 1 to n in a clockwise way. PolandBall repeats the following...
You should print n values separated by spaces. The i-th value should represent number of polygon's sections after drawing first i lines.
C
fc82362dbda74396ad6db0d95a0f7acc
52316c8744de17bde39d959d8c322de9
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures" ]
1484499900
["5 2", "10 3"]
NoteThe greatest common divisor (gcd) of two integers a and b is the largest positive integer that divides both a and b without a remainder.For the first sample testcase, you should output "2 3 5 8 11". Pictures below correspond to situations after drawing lines.
PASSED
2,000
standard input
4 seconds
There are only two numbers in the input: n and k (5 ≤ n ≤ 106, 2 ≤ k ≤ n - 2, gcd(n, k) = 1).
["2 3 5 8 11", "2 3 4 6 9 12 16 21 26 31"]
#include <stdio.h> int main() { long long int n, b=2, k, r; scanf("%I64d%I64d", &n, &k); printf("2 "); if(k>n/2) k=n-k; r=k; for(long long int i=1; i<2*k; ++i) { if(i!=1) { b+=i; printf("%I64d ", b); ++i; } for(long long int j=0; j<(n-r)/k; ++j) { b+=i; printf("%I64d ", b); } r=((...
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments. He chose a number k such that gcd(n, k) = 1. Vertices of the polygon are numbered from 1 to n in a clockwise way. PolandBall repeats the following...
You should print n values separated by spaces. The i-th value should represent number of polygon's sections after drawing first i lines.
C
fc82362dbda74396ad6db0d95a0f7acc
f6335eaf5998f12cd76927556decb8f6
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures" ]
1484499900
["5 2", "10 3"]
NoteThe greatest common divisor (gcd) of two integers a and b is the largest positive integer that divides both a and b without a remainder.For the first sample testcase, you should output "2 3 5 8 11". Pictures below correspond to situations after drawing lines.
PASSED
2,000
standard input
4 seconds
There are only two numbers in the input: n and k (5 ≤ n ≤ 106, 2 ≤ k ≤ n - 2, gcd(n, k) = 1).
["2 3 5 8 11", "2 3 4 6 9 12 16 21 26 31"]
#ifdef ONLINE_JUDGE #define NDEBUG 1 #endif #include <assert.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdint.h> #include <stdbool.h> #include <limits.h> #define long int64_t #define fore(i,k,n) for (int i = (int)(k); i <= (n); ++i) #define forr(i,n,k) for (int i = (int)(n); i >= (k);...
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments. He chose a number k such that gcd(n, k) = 1. Vertices of the polygon are numbered from 1 to n in a clockwise way. PolandBall repeats the following...
You should print n values separated by spaces. The i-th value should represent number of polygon's sections after drawing first i lines.
C
fc82362dbda74396ad6db0d95a0f7acc
bad390e8d6f2b22ffdf988ba3f55d9e0
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures" ]
1484499900
["5 2", "10 3"]
NoteThe greatest common divisor (gcd) of two integers a and b is the largest positive integer that divides both a and b without a remainder.For the first sample testcase, you should output "2 3 5 8 11". Pictures below correspond to situations after drawing lines.
PASSED
2,000
standard input
4 seconds
There are only two numbers in the input: n and k (5 ≤ n ≤ 106, 2 ≤ k ≤ n - 2, gcd(n, k) = 1).
["2 3 5 8 11", "2 3 4 6 9 12 16 21 26 31"]
/* Codeforces problem 755D */ #ifdef ONLINE_JUDGE #define NDEBUG 1 #endif #include <assert.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdint.h> #include <stdbool.h> #include <limits.h> #define long int64_t #define fore(i,k,n) for (int i = (int)(k); i <= (n); ++i) #define forr(i,n,k) fo...
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments. He chose a number k such that gcd(n, k) = 1. Vertices of the polygon are numbered from 1 to n in a clockwise way. PolandBall repeats the following...
You should print n values separated by spaces. The i-th value should represent number of polygon's sections after drawing first i lines.
C
fc82362dbda74396ad6db0d95a0f7acc
5e8adf5570c6bc19d3dbc45848ac6de9
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures" ]
1484499900
["5 2", "10 3"]
NoteThe greatest common divisor (gcd) of two integers a and b is the largest positive integer that divides both a and b without a remainder.For the first sample testcase, you should output "2 3 5 8 11". Pictures below correspond to situations after drawing lines.
PASSED
2,000
standard input
4 seconds
There are only two numbers in the input: n and k (5 ≤ n ≤ 106, 2 ≤ k ≤ n - 2, gcd(n, k) = 1).
["2 3 5 8 11", "2 3 4 6 9 12 16 21 26 31"]
#include<stdio.h> void update(long long int arr[],long long int n,long long int index) { long long int i; for(i=index;i<=n;i=i+(i&(-i))) arr[i]++; } long long int sumOfFirst(long long int arr[],long long int index) { long long int sum=0,i; for(i=index;i>0;i=i-(i&(-i))) sum=sum+arr[i]; r...
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments. He chose a number k such that gcd(n, k) = 1. Vertices of the polygon are numbered from 1 to n in a clockwise way. PolandBall repeats the following...
You should print n values separated by spaces. The i-th value should represent number of polygon's sections after drawing first i lines.
C
fc82362dbda74396ad6db0d95a0f7acc
cd5398f4672cac6499db5b8fdd6ba650
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures" ]
1484499900
["5 2", "10 3"]
NoteThe greatest common divisor (gcd) of two integers a and b is the largest positive integer that divides both a and b without a remainder.For the first sample testcase, you should output "2 3 5 8 11". Pictures below correspond to situations after drawing lines.
PASSED
2,000
standard input
4 seconds
There are only two numbers in the input: n and k (5 ≤ n ≤ 106, 2 ≤ k ≤ n - 2, gcd(n, k) = 1).
["2 3 5 8 11", "2 3 4 6 9 12 16 21 26 31"]
#include <stdio.h> #define N 1000000 /* Fenwick tree */ void update(int *tt, int n, int i, int x) { while (i < n) { tt[i] += x; i |= i + 1; } } long long query(int *tt, int i) { long long sum = 0; while (i >= 0) { sum += tt[i]; i &= i + 1; i--; } return sum; } int main() { static int tt[N]; long...
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments. He chose a number k such that gcd(n, k) = 1. Vertices of the polygon are numbered from 1 to n in a clockwise way. PolandBall repeats the following...
You should print n values separated by spaces. The i-th value should represent number of polygon's sections after drawing first i lines.
C
fc82362dbda74396ad6db0d95a0f7acc
33c6338b69361cabb7f2f56b495e0b61
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures" ]
1484499900
["5 2", "10 3"]
NoteThe greatest common divisor (gcd) of two integers a and b is the largest positive integer that divides both a and b without a remainder.For the first sample testcase, you should output "2 3 5 8 11". Pictures below correspond to situations after drawing lines.
PASSED
2,000
standard input
4 seconds
There are only two numbers in the input: n and k (5 ≤ n ≤ 106, 2 ≤ k ≤ n - 2, gcd(n, k) = 1).
["2 3 5 8 11", "2 3 4 6 9 12 16 21 26 31"]
#include<stdio.h> int main(void) { long long n, k, x = 1, y = 1, z = 1, flag = 0; scanf("%I64d %I64d", &n, &k); if (n - k < k){ k = n - k; } for (int i = 0; i < n; i++){ y += k; if (flag){ flag = 0; z++; } if (y > n){ z ++; flag = 1; y -= n; } x += z; if (i + 1 < n){ printf("%I64...
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments. He chose a number k such that gcd(n, k) = 1. Vertices of the polygon are numbered from 1 to n in a clockwise way. PolandBall repeats the following...
You should print n values separated by spaces. The i-th value should represent number of polygon's sections after drawing first i lines.
C
fc82362dbda74396ad6db0d95a0f7acc
bf0bd8050412a3b4ee8cdf76b6432995
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures" ]
1484499900
["5 2", "10 3"]
NoteThe greatest common divisor (gcd) of two integers a and b is the largest positive integer that divides both a and b without a remainder.For the first sample testcase, you should output "2 3 5 8 11". Pictures below correspond to situations after drawing lines.
PASSED
2,000
standard input
4 seconds
There are only two numbers in the input: n and k (5 ≤ n ≤ 106, 2 ≤ k ≤ n - 2, gcd(n, k) = 1).
["2 3 5 8 11", "2 3 4 6 9 12 16 21 26 31"]
#include <stdio.h> #include <string.h> #include <stdbool.h> #include <time.h> #define MAX 1000010 #define clr(ar) memset(ar, 0, sizeof(ar)) #define read() freopen("lol.txt", "r", stdin) int n, k; long long tree[MAX]; void update(int p, long long v){ p++; while (p <= n){ tree[p] += v; p += (p ...
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments. He chose a number k such that gcd(n, k) = 1. Vertices of the polygon are numbered from 1 to n in a clockwise way. PolandBall repeats the following...
You should print n values separated by spaces. The i-th value should represent number of polygon's sections after drawing first i lines.
C
fc82362dbda74396ad6db0d95a0f7acc
222e00db7efbf51a77a22216563ef657
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures" ]
1484499900
["5 2", "10 3"]
NoteThe greatest common divisor (gcd) of two integers a and b is the largest positive integer that divides both a and b without a remainder.For the first sample testcase, you should output "2 3 5 8 11". Pictures below correspond to situations after drawing lines.
PASSED
2,000
standard input
4 seconds
There are only two numbers in the input: n and k (5 ≤ n ≤ 106, 2 ≤ k ≤ n - 2, gcd(n, k) = 1).
["2 3 5 8 11", "2 3 4 6 9 12 16 21 26 31"]
#include<stdio.h> typedef long long unsigned llu; typedef unsigned u; u B[2222222],A[1111111],l; void inc(u x) { for(;x<=l;x+=x&-x)++B[x]; return; } u sum(u x) { u r=0; for(;x;x-=x&-x)r+=B[x]; return r; } int main() { u n,k,x=1,y,i=0;llu z=1llu; scanf("%u%u",&n,&k); if(k>n-k)k=n-k; for(l=n<<1;i++<n;x=y) { y...
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments. He chose a number k such that gcd(n, k) = 1. Vertices of the polygon are numbered from 1 to n in a clockwise way. PolandBall repeats the following...
You should print n values separated by spaces. The i-th value should represent number of polygon's sections after drawing first i lines.
C
fc82362dbda74396ad6db0d95a0f7acc
8bae10f3d7580d7fd992b7846e86d3df
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures" ]
1484499900
["5 2", "10 3"]
NoteThe greatest common divisor (gcd) of two integers a and b is the largest positive integer that divides both a and b without a remainder.For the first sample testcase, you should output "2 3 5 8 11". Pictures below correspond to situations after drawing lines.
PASSED
2,000
standard input
4 seconds
There are only two numbers in the input: n and k (5 ≤ n ≤ 106, 2 ≤ k ≤ n - 2, gcd(n, k) = 1).
["2 3 5 8 11", "2 3 4 6 9 12 16 21 26 31"]
#include <stdio.h> #include <stdlib.h> int gcd(int a,int b){ if(!(b%a)) return a; else return gcd(b%a,a); } int main(){ int n,k,i; scanf("%d %d",&n,&k); if(!((n>=5)&&(n<=1000000)&&(k>=2)&&(k<=n-2))){ exit(0); } if(gcd(n,k)!=1) exit(0); int arr[n]; ...
Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game.Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or...
If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked ...
C
1bd1a7fd2a07e3f8633d5bc83d837769
b45c0aee0722f42a2b82782fd212617a
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "greedy", "math" ]
1411218000
["1", "8"]
null
PASSED
1,500
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105).
["NO", "YES\n8 * 7 = 56\n6 * 5 = 30\n3 - 4 = -1\n1 - 2 = -1\n30 - -1 = 31\n56 - 31 = 25\n25 + -1 = 24"]
#include <stdio.h> #include <stdlib.h> int main() { long unsigned size, i; scanf("%lu", &size); if(size < 4) printf("NO\n"); else { printf("YES\n"); if(size % 2 == 0) { for(i = size; i > 4; i -= 2) { printf("%lu - %lu = 1\n", i, i - 1); ...
Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game.Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or...
If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked ...
C
1bd1a7fd2a07e3f8633d5bc83d837769
c51856a89430cbd9c1e90813ad26dc49
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "greedy", "math" ]
1411218000
["1", "8"]
null
PASSED
1,500
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105).
["NO", "YES\n8 * 7 = 56\n6 * 5 = 30\n3 - 4 = -1\n1 - 2 = -1\n30 - -1 = 31\n56 - 31 = 25\n25 + -1 = 24"]
/* practice with Dukkha */ #include <stdio.h> int main() { int n; scanf("%d", &n); if (n <= 3) { printf("NO\n"); return 0; } printf("YES\n"); while (n >= 6) { printf("%d - %d = 1\n", n, n - 1); printf("1 * 1 = 1\n"); n -= 2; } if (n == 4) { printf("1 * 2 = 2\n"); printf("2 * 3 = 6\n"); printf(...
Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game.Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and b, erase them from the sequence, and append to the sequence either a + b, or...
If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes). If there is a way to obtain 24 as the result number, in the following n - 1 lines print the required operations an operation per line. Each operation should be in form: "a op b = c". Where a and b are the numbers you've picked ...
C
1bd1a7fd2a07e3f8633d5bc83d837769
98c9e5f33273ad0e8aabedb6671c1a94
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "greedy", "math" ]
1411218000
["1", "8"]
null
PASSED
1,500
standard input
1 second
The first line contains a single integer n (1 ≤ n ≤ 105).
["NO", "YES\n8 * 7 = 56\n6 * 5 = 30\n3 - 4 = -1\n1 - 2 = -1\n30 - -1 = 31\n56 - 31 = 25\n25 + -1 = 24"]
#include <stdio.h> #include <stdlib.h> int main() { int n; scanf("%d",&n); if(n<=3) { printf("NO\n"); return 0; } printf("YES\n"); while(n>=6) { printf("%d - %d = 1\n",n,n-1); printf("1 * 1 = 1\n"); n-=2; } if(n==4) { printf("1...
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
C
b85c8bfbe67a23a81bef755f9313115a
f10a371ecc3c23cab53c28b7e0ed0c81
GNU C
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "number theory", "greedy" ]
1396798800
["5 2", "5 3", "7 2"]
Notegcd(x, y) is greatest common divisor of x and y.
PASSED
1,500
standard input
1 second
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
["1 2 3 4 5", "2 4 3 7 1", "-1"]
#include <stdio.h> int main() { int n,k,i,ch; scanf("%d %d",&n,&k); if(k<n/2&&n!=1) printf("-1"); else if(n!=1) { ch=k-n/2+1; //printf("%d ",n); printf("%d %d ",ch,2*ch); ch=2*ch+1; n=n-2; for(i=1;i<=n;i++) { printf("%d ",ch...
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
C
b85c8bfbe67a23a81bef755f9313115a
2e224f8386fc2b9e6f3562799a133b1f
GNU C
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "number theory", "greedy" ]
1396798800
["5 2", "5 3", "7 2"]
Notegcd(x, y) is greatest common divisor of x and y.
PASSED
1,500
standard input
1 second
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
["1 2 3 4 5", "2 4 3 7 1", "-1"]
#include <stdio.h> #include <string.h> int main(){ int n, k, i; // int map[101] = {0}; int count = 3; scanf("%d %d",&n,&k); if(k < n/2)printf("-1\n"); else{ if(!(n%2)){ for(i=0; i<n-2; i+=2){ while(count == k-(n-2)/2 || count == 2*k-n+2 || count+1 == k-(n-2)/2 |...
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
C
b85c8bfbe67a23a81bef755f9313115a
05a3917f19c78301c5714aa2bdb3c0e4
GNU C
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "number theory", "greedy" ]
1396798800
["5 2", "5 3", "7 2"]
Notegcd(x, y) is greatest common divisor of x and y.
PASSED
1,500
standard input
1 second
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
["1 2 3 4 5", "2 4 3 7 1", "-1"]
#include <stdio.h> int main() { int n,k,l,r,t,i,j; while(scanf("%d%d",&n,&k)!=EOF) { if(n==1) { if(k==0) printf("1\n"); else printf("-1\n"); continue ; } if(n/2>k) { printf("-1\n");continue ; ...
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he remov...
If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
C
b85c8bfbe67a23a81bef755f9313115a
78bfd1222da9c9a4c4529a8c75c0b320
GNU C
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "number theory", "greedy" ]
1396798800
["5 2", "5 3", "7 2"]
Notegcd(x, y) is greatest common divisor of x and y.
PASSED
1,500
standard input
1 second
The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).
["1 2 3 4 5", "2 4 3 7 1", "-1"]
#include<stdio.h> int main() { int n,k; int y; while(scanf("%d%d",&n,&k)!=EOF) { if(k<n/2||(n==1&&k!=0)) { printf("-1\n"); continue; } else if(n==1&&k==0) { printf("1\n"); continue; } y=k+1-n/2; printf("%d %d",y,y*2); for(int i=1;i<=n-2;i++) { printf(" %d",y*2+i); if(i=...
Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular...
In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arb...
C
ef82292a6591de818ddda9f426208291
385bbd718df0d55b5237c67da1f5d6ea
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures", "hashing" ]
1477922700
["6\n5 5 5\n3 2 4\n1 4 1\n2 1 3\n3 2 4\n3 3 4", "7\n10 7 8\n5 10 3\n4 2 6\n5 5 5\n10 2 8\n4 2 1\n7 7 7"]
NoteIn the first example we can connect the pairs of stones: 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. 2 and 6, the size of the...
PASSED
1,600
standard input
3 seconds
The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones.
["1\n1", "2\n1 5"]
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<time.h> #include<ctype.h> #include<limits.h> #define eps 1e-9 #define inf ((ll)1e18) #define clear(vis,i) memset(vis,i,sizeof(vis)) #define ll long long int #define N 230000 struct node{ int x,y,z; int ind; }arr[N*6]; int k=0; int cm...
Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular...
In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arb...
C
ef82292a6591de818ddda9f426208291
a154f61a05103c3867b5b920bf2892c2
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures", "hashing" ]
1477922700
["6\n5 5 5\n3 2 4\n1 4 1\n2 1 3\n3 2 4\n3 3 4", "7\n10 7 8\n5 10 3\n4 2 6\n5 5 5\n10 2 8\n4 2 1\n7 7 7"]
NoteIn the first example we can connect the pairs of stones: 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. 2 and 6, the size of the...
PASSED
1,600
standard input
3 seconds
The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones.
["1\n1", "2\n1 5"]
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<time.h> #include<ctype.h> #include<limits.h> #define eps 1e-9 #define inf ((ll)1e18) #define clear(vis,i) memset(vis,i,sizeof(vis)) #define ll long long int #define N 230000 struct node{ int x,y,z; int ind; }arr[N*6]; int k=0; int cm...
Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular...
In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arb...
C
ef82292a6591de818ddda9f426208291
977084112082d1a3502ca1642bb8c757
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures", "hashing" ]
1477922700
["6\n5 5 5\n3 2 4\n1 4 1\n2 1 3\n3 2 4\n3 3 4", "7\n10 7 8\n5 10 3\n4 2 6\n5 5 5\n10 2 8\n4 2 1\n7 7 7"]
NoteIn the first example we can connect the pairs of stones: 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. 2 and 6, the size of the...
PASSED
1,600
standard input
3 seconds
The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones.
["1\n1", "2\n1 5"]
#include <stdio.h> #include <stdlib.h> #define N 100000 #define MIN(A, B) ((A) < (B) ? (A) : (B)) struct cuboid { int j, a, b, c; } ss[3 * N]; void add(int i, int j, int a, int b, int c) { int tmp; if (a > b) tmp = a, a = b, b = tmp; ss[i].j = j; ss[i].a = a; ss[i].b = b; ss[i].c = c; } int compare(const ...
Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular...
In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arb...
C
ef82292a6591de818ddda9f426208291
64e91a1338c923b439bedabe08348b5d
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures", "hashing" ]
1477922700
["6\n5 5 5\n3 2 4\n1 4 1\n2 1 3\n3 2 4\n3 3 4", "7\n10 7 8\n5 10 3\n4 2 6\n5 5 5\n10 2 8\n4 2 1\n7 7 7"]
NoteIn the first example we can connect the pairs of stones: 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. 2 and 6, the size of the...
PASSED
1,600
standard input
3 seconds
The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones.
["1\n1", "2\n1 5"]
#include <stdio.h> #include <stdlib.h> #define N 100000 #define M 1000000007 #define MIN(A, B) ((A) < (B) ? (A) : (B)) int i1, i2, k; double max; struct item { int i, a, b, c; struct item *next; } *ht[N]; int hash(int a, int b) { long long hash = (11LL * ((71LL * a) + b)) % M; return (313LL * hash + 11LL) % M ...
Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular...
In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arb...
C
ef82292a6591de818ddda9f426208291
a9fabdbdc1795c9c2394c44f7b098d9c
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures", "hashing" ]
1477922700
["6\n5 5 5\n3 2 4\n1 4 1\n2 1 3\n3 2 4\n3 3 4", "7\n10 7 8\n5 10 3\n4 2 6\n5 5 5\n10 2 8\n4 2 1\n7 7 7"]
NoteIn the first example we can connect the pairs of stones: 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. 2 and 6, the size of the...
PASSED
1,600
standard input
3 seconds
The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones.
["1\n1", "2\n1 5"]
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <string.h> #define MIN(X,Y) ((X)<(Y) ? (X) : (Y)) int n,x[300010],y[300010],z[300010],ind[300010],o[300010]; void sort(int l,int r); void swap(int i,int j); int cmp(int i,int j); int main(void) { //freopen("sculptor.in","r",stdin)...
Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular...
In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arb...
C
ef82292a6591de818ddda9f426208291
5c44088712631fbc872ae7375a6aab96
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures", "hashing" ]
1477922700
["6\n5 5 5\n3 2 4\n1 4 1\n2 1 3\n3 2 4\n3 3 4", "7\n10 7 8\n5 10 3\n4 2 6\n5 5 5\n10 2 8\n4 2 1\n7 7 7"]
NoteIn the first example we can connect the pairs of stones: 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. 2 and 6, the size of the...
PASSED
1,600
standard input
3 seconds
The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones.
["1\n1", "2\n1 5"]
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MOD 1000000007 int cmpfunc(const void *a, const void *b){ return *(int*)a - *(int*)b; } int min(int a,int b){ return (a>b)?b:a; } int cmpf(const void *x, const void *y){ const int *a = (const int *)x; const int *b = (const int *)y; i...
Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular...
In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arb...
C
ef82292a6591de818ddda9f426208291
8d264fb43336adb21c52045ce5ec1875
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures", "hashing" ]
1477922700
["6\n5 5 5\n3 2 4\n1 4 1\n2 1 3\n3 2 4\n3 3 4", "7\n10 7 8\n5 10 3\n4 2 6\n5 5 5\n10 2 8\n4 2 1\n7 7 7"]
NoteIn the first example we can connect the pairs of stones: 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. 2 and 6, the size of the...
PASSED
1,600
standard input
3 seconds
The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones.
["1\n1", "2\n1 5"]
#include<stdio.h> #include<string.h> #include<stdlib.h> #define N 100005 struct node { int a,b,c; int index; }q[N*3]; int head,tail; int cmp(const void *a,const void *b) { return *(int *)a-*(int *)b; } int ccmp(const void *a,const void *b) { struct node k1=*(struct node *)a; struct node k2=*(struct ...
Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere. Zahar has n stones which are rectangular...
In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data. You can print the stones in arb...
C
ef82292a6591de818ddda9f426208291
b46eeac1c609d0d4ce5c5b7c0058804a
GNU C
standard output
256 megabytes
train_002.jsonl
[ "data structures", "hashing" ]
1477922700
["6\n5 5 5\n3 2 4\n1 4 1\n2 1 3\n3 2 4\n3 3 4", "7\n10 7 8\n5 10 3\n4 2 6\n5 5 5\n10 2 8\n4 2 1\n7 7 7"]
NoteIn the first example we can connect the pairs of stones: 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5 respectively. 2 and 6, the size of the...
PASSED
1,600
standard input
3 seconds
The first line contains the integer n (1 ≤ n ≤ 105). n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones.
["1\n1", "2\n1 5"]
#include <stdio.h> #define ARRSORTSIZE 3 #define MAX 100010 struct st_arr_sort { int container[ARRSORTSIZE]; int index; int length; }; typedef struct st_arr_sort __asort; int qs(int items[], int left, int right) { int i, j, x, y; i = left; j = right; x = items[(left+right)/2]; do { while((items[i]>x) && (i<...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
c3b7ebfbaa300f35051e8607c1493342
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> int main() { int T,i,l; char t[101]; scanf("%d",&T); while(T--){ scanf("%s",t); l=0; for(i=0;i<strlen(t);i++){ if(t[i]!=t[0]){ l++; } } if(l==0){ printf("%s\n",t); } else{ ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
04b064b87806a0f239136801bfb8cf1e
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> int main(){ int t; scanf("%d",&t); while(t--){ char s[101]; int x=0; scanf("%s",s); int n=strlen(s); for(int i=0;i<n-1;i++){ if(s[i]!=s[i+1]) x=1; } if(x==0) printf("%s",s); if(x==1){ for(...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
42feb36340f1ab2576c3426131eb9674
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> void main(void){ int t; scanf("%d", &t); while(t--){ char A[107]; scanf("%s", A); int x=0, y=0, len=0; for(int i=0; A[i]!='\0'; i++){ len++; if(A[i]=='1'){ x=1; }else{ y=1; } ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
c9b362387b67fe4cad350d67961c5931
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <string.h> #include <stdlib.h> #define REVERSE(x) ((x) == '1' ? '0' : '1') int has_0_1_only(const char *bits) { while (*++bits) { if (*bits != *(bits - 1)) return 0; } return 1; } void do_your_thing(const char *bits) { while (*bits) { putchar(*bits); if (*bits == *(bits...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
b0979f20ae9cd6bcbe8b99c779b5e442
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <stdlib.h> #include<string.h> int main() { int T,i; scanf("%d",&T); getchar(); for(i=1;i<=T;i++){ char str[200]; scanf("%s",str); int len,sum=0; len=strlen(str); int j; for(j=0;j<len;j++){ sum+=(str[j]-'0'); ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
c3a7689902c8bedc10eb190e95a23890
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <string.h> int main(){ int p; scanf("%i",&p); while(p--){ int i,x=0,y=0; char t[101]; scanf("%s",t); for(i=0;i<strlen(t);i++){ if(t[i]=='1') x++; if(t[i]=='0') y++; } if(x*y) ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
93fea9429af269dab771ab16656a3851
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<ctype.h> #include<limits.h> #include<float.h> #include<math.h> #include<stdbool.h> #include<stdio.h> #include<stdlib.h> #include<string.h> #define min(x, y) ((x<y) ? x : y) #define max(x, y) ((x<y) ? y : x) #define loop(a, b, c) for(long long int a = b; a < c; a++) #define loop_(a, b, c) for(long long int a = ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
676dc88493275bcc8e5eec5d79d9941f
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <string.h> int main() { int T, l, cnt0, cnt1, i; char ch[110], c; scanf("%d", &T); while (T--) { scanf("%s", ch); l=strlen(ch);cnt0=0; cnt1=0; for (i=0; i<l; i++) { if (ch[i]=='0') cnt0++; else cnt1++; } if (cnt...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
0a6ffb6b509e509f424bbea01e64df37
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <string.h> void insert(char* s,int index,char c) { for(int i=strlen(s)-1;i>index;i--){ printf("cdcd%d\n",index); s[i]=s[i-1]; } s[index]=c; } int main() { int t; scanf("%d",&t); while(t--){ char str[144]={0},str2[344]={0}; scanf("%s\n...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
7a12fef621cab16e471d58cefc723c24
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #define M 105 int main() { int t; scanf("%d",&t); char ch1=getchar(); while(t){ int i,n=0,tag1=0,tag2=0; char ch; char s[M]; while((ch=getchar())!='\n'){ s[n++]=ch; } s[n]='\0'; for(i=0;i<n;i++){ if(s[i]=='0') tag1++; if(s[i]=='1') tag2++; } if(tag1>0&&tag2>0){ ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
c64c15e349192134f915c029d06c4ea2
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> int main(){ int t; scanf("%d", &t); char ts[102]; while(t--){ scanf("%s", &ts); char check = ts[0]; int d = 0; int len = strlen(ts); for(int i = 0; i < len; i++){ if(ts[i] != check){ d = 1; } } if(d == 1){ char s[205]; int cou = 0; ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
9d486114e7ae8a4eb6e30d528a2990c9
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> int main() { int t,x,i,j,k,f; scanf("%d",&t); while(t--) { char n[105],ch1,ch2; scanf("%s",n); x=strlen(n); int a=0,b=0; if(x<=2) { printf("%s\n",n); continue; } for(i=0;i<x-1;i++) { if(n[i]==n[i+1]...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
e701c5401db119405de09c49046cf8fb
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int main() { // variable in description int T; char t[200]; // variable to support int L; int num_0; // variable to judge int i; int j; int k; scanf("%d",&T); for(i=0;i<T;i++) { for(j=0;j<150;j++) { t[j] = 0; } scan...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
edd8ca2f7b39ae427f891de2d96c882b
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> int main() { int t, i, k, h; char s[101]; scanf("%d", &t); while(t--) { scanf("%s", s); int x=0, y=0, r=1; for(i=0; s[i]!='\0'; i++) { if(s[i]=='1'){ x++; } else{ y++; } } if(x==0 || y==0 || i==2) { printf("%s", s); } else { int a[2*i+1]; a[...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
7f5b2fcd5d9036e53c8a8ace438cd6df
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <math.h> #include <string.h> int main(void) { int t; scanf("%d\n",&t); char str[109],ans[300]; int i,j,flag,len; char init; while(t--){ scanf("%s",str); len=strlen(str); init=str[0]; j=0;flag=0; for(i=0;i<len;i++){ if(str[i]=='0'){ ans[j+...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
ab39ff21fb856d8615a3690cf182e33a
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int te; scanf("%d",&te); while(te--) { char t[108]; scanf("%s",t); int countone,countzero,len; len=strlen(t); countone=0,countzero=0; for(int i=0;i<len;i++) { if(t[i]=='1') ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
6e0710f04ee8539f6e16ec232484b35f
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int te; char s[202],t[102]; scanf("%d",&te); while(te--) { scanf("%s",t); int count1,count0; count1=0,count0=0; for(int i=0;i<strlen(t);i++) { if(t[i]=='1') count1++; ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
7a2d0f998f5ecdce1fc85f3ac301a693
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int te; scanf("%d",&te); while(te--) { char t[108]; scanf("%s",t); int countone,countzero,len; len=strlen(t); countone=0,countzero=0; for(int i=0;i<len;i++) { if(t[i]=='1') ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
fd7c0f31035bf994c4651a1b2171f6b6
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include<string.h> int main() { int t; scanf("%d",&t); while(t--) { char t[108]; scanf("%s",t); int zero=0,one=0,i,len=strlen(t); for(i=0;i<len;i++) { if(t[i]=='0') zero++; else one++; } if(zero==len || one==len) { printf("%s\n",t); continue; ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
b3d6bc36f5890f94e43c1df8c5e5e174
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> int main() { int i,j,m,n,t,same,l; char str[109],c,d; scanf("%d", &t); for(i=0;i<t;i++){ scanf("%s", str); l=strlen(str); same=0; if(str[0]=='0'){ c='0'; d='1'; } else if(str[0]=='1'){ ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
48a616f57be6ce5fa5187b66adc75ce9
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> int main() { int t,i,flag=0; char s[100]; scanf("%d",&t); while(t--) { flag=0; scanf("%s",s); for(i=1;i<(strlen(s));i++) { // printf("%s",s); if(s[i-1]!=s[i]) flag=1; } if(...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
c483e834c5164d2e6c2ad4e7defa2c17
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> int main() { int n; scanf("%d",&n); for(;n>0;n--) { char t[110]; int a,b,c=0; scanf("%s",t); a=strlen(t); for(b=0;b<a;b++) { if(t[b]=='0') c++; } if(c==a||c==0) pr...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
4e12b4e891c93bc4462f27864a86b1db
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> int main() { int t,i,c; char s[101]; scanf("%d",&t); while(t--){ scanf("%s",s); c=0; for(i=0;i<strlen(s);i++){ if(s[i]!=s[0]){ c++; } } if(c==0){ printf("%s\n",s); } else{ ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
268e261e360786d9a122955bebadff85
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include<string.h> int main() { int tc; scanf("%d",&tc); while(tc--){ char t[108]; scanf("%s",t); int zero=0,one=0,i,len=strlen(t); for(i=0;i<len;i++){ if(t[i]=='0') zero++; else one++; } if(zero==len||one==len){ printf("%s\n",t);continue;} for(i=0;i<2*len;i++) printf...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
d88e7da9fb14a1ddb7e605fdf501a893
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #define N 102 int main(){ int T; scanf("%d",&T); char t[N]; while(T--){ scanf("%s",t); int i; int one=0; int zero=0; for(i=0;t[i]!='\0';i++){ if(t[i]=='0'){ zero++; }else{ one++; ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
bc64db2a4c0fcde5a90cd121ebc1ee13
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> int main() { int t,n,i,j; scanf("%d",&t); while(t--) { char x[101]; scanf("%s",x); n=strlen(x); for(i=1;i<n;i++) { if(x[i]!=x[0]) break; } if(i==n) printf("%s\n",x); else { for(i=0;i<n...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
aa0cd7b0073751875842849aca32c840
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int t; scanf("%d", &t); for (int i = 0; i < t; i++) { char* test = malloc(101*sizeof(int)); scanf("%s", test); int is_constant = 1; for (int i = 1; i < strlen(test); i++) { if (test[i] != test[i-1]) is_constant = 0; ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
449530289eecb244f50ed194b8ac9182
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> char s[110]; int main () { int t; scanf("%d",&t); while(t--) { scanf("%s",s); int len=strlen(s); // printf("%d",len); int flag=0; for(int i=0;i<len;i++) { if(s[i]=='0') flag++; } if(flag==0||flag==len) printf("%s",s); else { char ch='...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
a9c84a7466f576d300634de375c3012b
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> int main() { int t,i,c,x; char s[101]; scanf("%d",&t); while(t--){ c=0; scanf("%s",&s); x=strlen(s); for(i=1;i<x;i++){ if(s[0]!=s[i]){ c=2; break;} } if(c==2){ if(s[0]=='0'){ for(i=0;i<2*x;i++){ if(i&1) printf("1"); else printf("0"); }} else{ for...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
2e4aeb5cb91b2d4618387be9c9e7ca6c
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> int main() { int t,one,i; char s[105]; scanf("%d",&t); while(t--) { one=0; scanf("%s",s); for(i=0;s[i]!='\0';i++) { if(s[i]=='1') ++one; } if(one==0||one==strlen(s)) printf("%s",s...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
a86ae3519f5d0102f166a264ba71d36e
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> int t,x,h; int main() { char str[100]; scanf("%d",&t); while(t--) { h=0; scanf("%s",str); for(x=0;x<strlen(str)-1;x++) { if(str[x]!=str[x+1]) { h=1; break; } else h=0; } if(h==0) { printf("%s\n",str); } else ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
9fc30748498f587c04583e1af4ed43cd
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> int main() { int len,count0,count1,T,l,i; scanf("%d",&T); for(l=1;l<=T;l++){ char t[100]; scanf("%s",&t); len=strlen(t); count0=0; count1=0; for(i=0;i<len;i++){ if(t[i]=='1') count1++; ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
ff2eff5d5488fa3e8775afcc8ce2a484
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> int main(){ int time; scanf("%d",&time); int ti; for(ti=0;ti<time;ti++){ char t[200]; scanf("%s",t); int num1=0; int num0=0; int i; int judge=-1; for(i=0;i<strlen(t);i++){ if(t[0]=='0'){ judge=0; ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
ec48174e115d123bdb0ce6536b5007c7
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> int main() { char a[4000]; long long i,t,c,d,n,j,x,q,count,temp,p,per; scanf("%lld",&t); for(i=0;i<t;i++) { scanf("%s",a); n=strlen(a); p=0;q=0; for(j=0;j<n;j++) { if(a[j]=='0') {p++;} else{q++;} } ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
d3a02c9c28abfb21414b67d5b156cd11
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> #include<math.h> #define ll long long int #define P 1000000007 int cmpfunc (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } ll min(ll a,ll b){ if(a<b)return a;return b; } ll max(ll a,ll b){ if(a>b)return a;return b; } int bs(int arr[],int l,int r,int x){...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
85b5f54da51d316ccbd2fd98ecc72269
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <stdlib.h> int main() { int t; scanf("%d",&t); while(t--) { char str[100+5]; int i,s,one=0,zero=0; scanf("%s",str); s=strlen(str); for(i=0; i<s; i++) { if(str[i]=='1') one++; else ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
02b9df9c4c267729e389be21c270d6fb
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> int main() { int T,i; scanf("%d",&T); for(i=1;i<=T;i=i+1) { int j=0,u=0,v=0,k; char t[101]; scanf("%s",&t); while(t[j]!=0) { if(t[j]=='1') { v=1; } if(t[j]=='0') { ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
bdf6fef9654a5c4a8237134a1a89d17e
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> int main() { int t; scanf("%d",&t); while(t--) { int z=0,o=0,n,i; char s[1000]; scanf("%s",s); n=strlen(s); for(i=0;i<n;i++) { if(s[i]=='0') { z=z+1; ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
8251eb1b76afa8e166535c384b7d57b9
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include <string.h> int main(){ int t,i,c=1; char s[1024]; scanf("%d ",&t); while(t--){ c=1; scanf("%s",&s); for(i=0;i<strlen(s)-1;i++){ if(s[i]!=s[i+1]){ c=0; break; } } if(c==1){ ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
3bbf6a5bed67fb010e93142896a70eea
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include <string.h> int main(){ int t,i,c=1; char s[1024]; scanf("%d ",&t); while(t--){ c=1; scanf("%s",&s); for(i=0;i<strlen(s)-1;i++){ if(s[i]!=s[i+1]){ c=0; break; } } if(c==1){ ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
ecc811c07c203648d237e496c5c2c993
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <string.h> int main() { int i,l,t; char s[100],ans[100]; scanf("%d",&t); while(t--) { scanf("%s",s); l=strlen(s); int one=0,zero=0; for(i=0;i<l;i++) { if(s[i]=='0') zero++; if(s[i]=='1') one++; } if(zero>0 && one>0) { for(i=0;i<l;i++) { printf("10")...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
66f9c2a6733eff69bc55e9d416436987
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> #include <string.h> #define N 100 char s[N + 1]; int main () { int t, i, len, o, z, f; scanf("%d\n", &t); while (t--) { scanf("%s", s); len = strlen(s), o = z = 0; for (i = 0; i < len; i++) { if (s[i] == '0') ++z; else ++o; } if (o == len || z == len) { printf("%s\n", s)...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
5443ac316ebe47974cb98c79099df26d
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> int main() { int t,n,i,j; scanf("%d",&t); while(t--) { char x[101]; scanf("%s",x); n=strlen(x); for(i=1;i<n;i++) { if(x[i]!=x[0]) break; } if(i==n) printf("%s\n",x); else { for(i=0;i<n...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
ea8ff1af9ca3d269f66c5b64a28e546e
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include<stdio.h> #include<string.h> int main() { // your code goes here int t; scanf("%d",&t); while(t--) { char a[101]; scanf("%s",a); int c=0; for(int i=0;i<strlen(a);i++) { if(a[i]=='0') c++; } if(c==0||c==strlen(a)) { printf("%s",a); } ...
Let's say string $$$s$$$ has period $$$k$$$ if $$$s_i = s_{i + k}$$$ for all $$$i$$$ from $$$1$$$ to $$$|s| - k$$$ ($$$|s|$$$ means length of string $$$s$$$) and $$$k$$$ is the minimum positive integer with this property.Some examples of a period: for $$$s$$$="0101" the period is $$$k=2$$$, for $$$s$$$="0000" the perio...
Print one string for each test case — string $$$s$$$ you needed to find. If there are multiple solutions print any one of them.
C
679a1e455073d3ea3856aa16516ba8ba
bf92e3f331f478c5433e6ad6981682f8
GNU C11
standard output
256 megabytes
train_002.jsonl
[ "constructive algorithms", "strings" ]
1587911700
["4\n00\n01\n111\n110"]
NoteIn the first and second test cases, $$$s = t$$$ since it's already one of the optimal solutions. Answers have periods equal to $$$1$$$ and $$$2$$$, respectively.In the third test case, there are shorter optimal solutions, but it's okay since we don't need to minimize the string $$$s$$$. String $$$s$$$ has period eq...
PASSED
1,100
standard input
2 seconds
The first line contains single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of test cases. Next $$$T$$$ lines contain test cases — one per line. Each line contains string $$$t$$$ ($$$1 \le |t| \le 100$$$) consisting only of 0's and 1's.
["00\n01\n11111\n1010"]
#include <stdio.h> int v[100]; int main(){ int t, n, i, x; char ch; scanf("%d ", &t); while(t--){ ch=fgetc(stdin); n=0; while(ch!='\n'){ v[n++]=ch-'0'; ch=fgetc(stdin); } x=v[0]; i=1; while(i<n && v[i]==x) i++; if(i==n){ for(i=0; i<n; i++) printf("...