zoukankan      html  css  js  c++  java
  • 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("
    ");
        }
    
    //  fin.close();
        return 0;
    }
    
  • 相关阅读:
    makefile学习之路
    DiagramDesigner的学习心得一
    MvvmLight的Message使用
    MvvmLight学习心得三
    Nancy学习心得一
    WPF的类似WinForm中的托盘
    py学习记录#10
    PY期末习题全解析
    py学习记录#11
    PY学习记录#9
  • 原文地址:https://www.cnblogs.com/ramanujan/p/3413025.html
Copyright © 2011-2022 走看看