import java.util.*;
public class Main {
public static void main
(String[] args
) { Scanner sc
= new Scanner
(System.
in); int n = sc.nextInt();
System.
out.
println(findMaxPartitions
(s, n
)); }
public static int findMaxPartitions
(String s,
int n
) { for (int len = 1; len <= n; len++) {
if (n % len != 0) continue; // 子串长度必须能整除整个字符串的长度
if (canBePartitioned(s, len)) {
return n / len;
}
}
return 1;
}
private static boolean canBePartitioned
(String s,
int len
) { for (int i = 0; i < s.length(); i += len) {
substrings[i / len] = s.substring(i, i + len);
}
// 检查所有子串是否可以通过交换变成相同的内容
Map
<Character, Integer
> baseFrequency
= getFrequency
(substrings
[0]); for (int i = 1; i < substrings.length; i++) {
if (!baseFrequency.equals(getFrequency(substrings[i]))) {
return false;
}
}
return true;
}
Map
<Character, Integer
> frequencyMap
= new HashMap
<>(); for (char c : str.toCharArray()) {
frequencyMap.put(c, frequencyMap.getOrDefault(c, 0) + 1);
}
return frequencyMap;
}
}
aW1wb3J0IGphdmEudXRpbC4qOwoKcHVibGljIGNsYXNzIE1haW4gewogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIFNjYW5uZXIgc2MgPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwogICAgICAgIGludCBuID0gc2MubmV4dEludCgpOwogICAgICAgIFN0cmluZyBzID0gc2MubmV4dCgpOwogICAgICAgIAogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihmaW5kTWF4UGFydGl0aW9ucyhzLCBuKSk7CiAgICB9CgogICAgcHVibGljIHN0YXRpYyBpbnQgZmluZE1heFBhcnRpdGlvbnMoU3RyaW5nIHMsIGludCBuKSB7CiAgICAgICAgZm9yIChpbnQgbGVuID0gMTsgbGVuIDw9IG47IGxlbisrKSB7CiAgICAgICAgICAgIGlmIChuICUgbGVuICE9IDApIGNvbnRpbnVlOyAvLyDlrZDkuLLplb/luqblv4Xpobvog73mlbTpmaTmlbTkuKrlrZfnrKbkuLLnmoTplb/luqYKICAgICA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