当前位置:编程学习 > C/C++ >>

hust 校赛 Substring

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; 

 

 

补充:软件开发 , C++ ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,