hust 1602, 乱搞

D - Substring
Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu

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
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<cstdlib>
#include<algorithm>

using namespace std;

#define LL long long
#define ULL unsigned long long
#define UINT unsigned int
#define MAX_INT 0x7fffffff
#define MAX_LL 0x7fffffffffffffff
#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))

int main(){
//  fstream fin("C:\\Users\\Administrator\\Desktop\\in.txt",ios::in);

    const char s[]="XHUSTACM";
    LL l,r;
    while(cin>>l>>r){
        LL i=0,len=strlen(s);
        LL j=(l-1)%len;
        for(i=0; i<r-l+1; i++){
            printf("%c",s[j]);
            j=(j+1)%len;
        }
        printf("\n");
    }

//  fin.close();
    return 0;
}

 

posted @ 2013-11-07 18:41  Ramanujan  阅读(180)  评论(0编辑  收藏  举报