the counting method of 1140 jam
2006 NOIP National League popularity Group
time limit: 1 sspace limit: 128000 KBtitle level: Golden GoldTitle Description
Description
Jam is a science geek who likes to be unconventional. He does not use Arabic numerals, but uses lowercase English letters to count, and he feels that doing so will make the world more colorful. In his notation, the digits of each digit are the same (using the same number of letters), the letters are in the original order, the letters in front of them are smaller than the letters that follow them. We call this "number" jam numbers. In jam numbers, each letter differs from left to right and is strictly incremented. Each time, jam also specifies the range of letters used, for example, from 2 to 10, which means that only {B,C,D,E,F,G,H,I,J} letters can be used. If the number of digits is 5, then the number immediately after the jam number "Bdfij" should be "Bdghi". (If we use U, V to indicate jam number "Bdfij" and "Bdghi", then u<v< Span>, and there is no jam number P, so u<p<v< span>). Your task is: For a jam number read from the file, sequentially output the 5 jam numbers immediately following, if there are not so many jam numbers, then a few will output a few.
Enter a description
Input Description
There are 2 lines, the 1th Act 3 positive integers, separated by a space:
S T W
(where S is the ordinal of the smallest letter used, T is the ordinal of the largest letter used.) W is the number of digits, these 3 numbers meet:1≤s<t< span>≤26, 2≤w≤t-s)
The 2nd behavior has a W lowercase string, which is a required jam number.
The data given is correct and does not have to be verified.
Output description
Output Description
A maximum of 5 rows, the 5 jam numbers immediately following the input jam number, if there are not so many jam numbers, then a few will output a few. Output only one jam number per line, which is a string of W lowercase letters, no extra spaces
Sample input
Sample Input
2 10 5
Bdfij
Sample output
Sample Output
Bdghi
Bdghj
Bdgij
Bdhij
Befgh
#include <iostream>#include<string>using namespacestd;intMain () {intS,t,w,count=0, si; stringstr; CIN>>s>>t>>w>>str; while(count<5) { for(inti=w-1; i>=0; i--) {Si=str[i]-'a'+w-i;//determine if the boundary is reached if(si<t) {Str[i]=str[i]+1;//The first number pushes backwards . for(intj=i+1; j<w; J + +) Str[j]=str[j-1]+1;//second and subsequent numbers push forward, no + 1 letters will overlapcount++; cout<<str<<Endl; Break; } } } return 0;}
The method of counting jam