300645: CF123A. Prime Permutation
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Prime Permutation
题意翻译
给出一个字符串,问能否通过打乱它的顺序得到一个新的字符串,这个字符串满足所有的质数位和位数是这个质数的倍数的位数上的字母相同,输出能否,如果能,构造一组解.题目描述
You are given a string $ s $ , consisting of small Latin letters. Let's denote the length of the string as $ |s| $ . The characters in the string are numbered starting from $ 1 $ . Your task is to find out if it is possible to rearrange characters in string $ s $ so that for any prime number $ p<=|s| $ and for any integer $ i $ ranging from $ 1 $ to $ |s|/p $ (inclusive) the following condition was fulfilled $ s_{p}=s_{p×i} $ . If the answer is positive, find one way to rearrange the characters.输入输出格式
输入格式
The only line contains the initial string $ s $ , consisting of small Latin letters ( $ 1<=|s|<=1000 $ ).
输出格式
If it is possible to rearrange the characters in the string so that the above-mentioned conditions were fulfilled, then print in the first line "YES" (without the quotes) and print on the second line one of the possible resulting strings. If such permutation is impossible to perform, then print the single string "NO".
输入输出样例
输入样例 #1
abc
输出样例 #1
YES
abc
输入样例 #2
abcd
输出样例 #2
NO
输入样例 #3
xxxyxxx
输出样例 #3
YES
xxxxxxy