The remaining group continues to traverse the caves when suddenly, they are ambushed! Gigantic spiders tear Tom to pieces, and in the scuffle, Paul is pinned to the ground by a falling boulder. Max, Mehdi, Joey and Alex have no choice but to leave Paul behind as the spider creatures swarm over him. He is gone now.
To cheer up the group, Max tells the group about funny anagrams, an anagram of a base string that contains a funny substring. For example, Boris's name anagrams to "Bikini Rhos Rusk", which contains the word "Bikini". Now isn't that quite hilarious! Given a base string and funny substring, tell Max how many funny anagrams he can make!
Here are the rules of anagramming, according to an interview with Master Max
himself.
Well, my rules are sort of different. First, I get just enough of my alphabet toys to spell out the base string. Then, I use some of them to spell out the funny substring, and I glue them together in order. I now consider the substring as a single, unique character. I can't move any individual alphabet toys from the substring anymore, as they are glued together, but I can move the entire substring around. Afterward, I mix them up and see how many combinations I can make!
Input Specification
The input will consist of lowercase alphabet characters (a
-z
) and a newline.
The first line of input has the funny substring, with length . The characters may repeat in any way.
The second line of input will have the base string, with length .
Output Specification
A single integer: The number of funny anagrams that Max can create (modulo ).
Sample Input
ab
aab
Sample Output
2
Explanation
Max glues an a
and b
together from the base string to get the unique character ab
. By the definition of an anagram, he has to use the remaining a
from the base string:
An anagram is a type of wordplay, the result of rearranging the letters of a word or phrase to produce a new word or phrase, using all the original letters exactly once.
Therefore Max can make two anagrams, a
+ab
and ab
+a
.
Comments
Is his comment still true, or is the problem edited?
If the base string is aabcd, and the funny string is bcd, then is a + bcd + a the same thing as the two a's swapped?
Yes. Again, Max will not be able to supervise this contest.
Max
First of all, don't make announcements in the problem statement. That's what the comment section is for.
Second of all, if your statement and testdata disagree, the only way to handle it professionally is to make the data confirm to the statement, not the other way around.
Please refer to https://dmoj.ca/help/externalcontests/.
Thanks.
In the case:
Is the answer 1 or 2?
Hello dear friend, colleague and fellow software programmer. The answer to this conundrum is .
In fact, this input is not valid.
In the substring.
In the substring.
Edit sry for repost sent from the road
I will edit the problem when I get back soon
Even with all repeated letters the problem is still solvable w/o nontrivial additions to same code
Sorry for all inconveniences
Also who tf is GHETTO?