Time Limit: 2 Sec Memory Limit: 64 MB
Submissions: 251 Solved: 37
Description
This problem is quiet easy.
Initially, there is a string A.
Then we do the following process infinity times.
A := A + “HUSTACM” + A
For example, if a = “X”, then
After 1 step, A will become “XHUSTACMX”
After 2 steps, A will become “XHUSTACMXHUSTACMXHUSTACMX”
Let A = “X”, Now I want to know the characters from L to R of the final string.
Input
Multiple test cases, in each test case, there are only one line containing two numbers L and R.
1 <= L <= R <= 10^12
R-L <= 100
Output
For each test case, you should output exactly one line which containing the substring.
Sample Input
5 10
Sample Output
TACMXH
HINT
Source
Problem Setter : Yang Xiao
寫出幾個 一看就知道規律了
[cpp]
#include<stdio.h>
#include<string>
#include<iostream>
#include<string.h>
int a[1000];
using namespace std;
int main()
{
__int64 left,right;
char s[]="XHUSTACM";
while(scanf("%I64d %I64d",&left,&right)!=EOF)
{
left--;right--;
int len=right-left+1;
puts(s);
left=left%8;
while(len--)
{
printf("%c",s[left]);
left=(left+1)%8;
}
printf("\n");
}
return 0;
}