CF123A.Prime Permutation

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a string ss , consisting of small Latin letters. Let's denote the length of the string as s|s| . The characters in the string are numbered starting from 11 .

Your task is to find out if it is possible to rearrange characters in string ss so that for any prime number p<=sp<=|s| and for any integer ii ranging from 11 to s/p|s|/p (inclusive) the following condition was fulfilled sp=sp×is_{p}=s_{p×i} . If the answer is positive, find one way to rearrange the characters.

输入格式

The only line contains the initial string ss , consisting of small Latin letters ( 1<=s<=10001<=|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
    

说明/提示

In the first sample any of the six possible strings will do: "abc", "acb", "bac", "bca", "cab" or "cba".

In the second sample no letter permutation will satisfy the condition at p=2p=2 ( s2=s4s_{2}=s_{4} ).

In the third test any string where character "y" doesn't occupy positions 2, 3, 4, 6 will be valid.

首页