-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSWEA2007.java
More file actions
72 lines (55 loc) · 1.45 KB
/
SWEA2007.java
File metadata and controls
72 lines (55 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.study.code.solved;
import java.util.Scanner;
public class SWEA2007 {
private static Scanner sc;
public static void main(String[] args) {
sc = new Scanner(System.in);
int tcN = sc.nextInt();
char[] madi = new char[10];
for (int tc = 1; tc <= tcN; tc++) {
String text = sc.next();
int minLength = 10;
for(int i = 0; i < 10; i++) {
madi[i] = text.charAt(i);
}
// for(int i = 0; i < 10; i++) {
// System.out.print(madi[i]);
// }
// System.out.println();
//madi 길이가 10이야
//전체 길이 % 10 하면 그 인덱스끼리 다 같아야해
boolean match = true;
for(int i = 1; i < 11; i++) {
match = true;
for(int j = 0; j < 30; j++) {
//System.out.println(j + "ori = " + text.charAt(j));
//마디가 길이가 1이면
//마디 0번째랑 0번째문자랑 비교
//마디가 길이가 2이면
//마디 0번째랑 0번째문자
if(j%i == 0) {
//System.out.println(j + "madi = " + madi[0]);
if(text.charAt(j) != madi[0]) {
//System.out.println("false");
match = false;
break;
}
}else {
//System.out.println(j + "madi = " + madi[j%i]);
if(text.charAt(j) != madi[j%i]) {
//System.out.println("false");
match = false;
break;
}
}
if(j == 29 && match) {
//System.out.println(i);
minLength = Math.min(minLength, i);
}
}
}
System.out.println("#"+ tc + " " + minLength);
}
sc.close();
}
}