程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> hust 校賽 Substring

hust 校賽 Substring

編輯:C++入門知識

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; 

 

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved