zoukankan      html  css  js  c++  java
  • 门(door)

    门(door)

    时间限制: 1 Sec  内存限制: 128 MB

    题目描述

     

    输入

    第一行是一个正整数n,表示原始字符串的长度。第二行是一个字符串,长度为n。字符串由大小写字母,数字,符号,空格构成。

    输出

    若干行,表示转化后的字符串。每76个字符为一行,如果最后一行不满76个字符,也换一行。因为是逐字节比较,行末不能有多余空格,文末不能有多余空行(也就是说文件最后一行一定是空行,倒数第二行一定不是空行)。

    样例输入

    425
    1.If you shed tears when you miss the sun, you also miss the stars.2.I cannot choose the best. The best chooses me.3.We read the world wrong and say that it deceives us.4.Let life be beautiful like summer flowers and death like autumn leaves.5.Let this be my last word, that I trust in thy love.6.The little flower lies in the dust. It sought the path of the butterfly.7.Life has become richer by the love that has been lost.

    样例输出

    MS5JZiB5b3Ugc2hlZCB0ZWFycyB3aGVuIHlvdSBtaXNzIHRoZSBzdW4sIHlvdSBhbHNvIG1pc3Mg dGhlIHN0YXJzLjIuSSBjYW5ub3QgY2hvb3NlIHRoZSBiZXN0LiBUaGUgYmVzdCBjaG9vc2VzIG1l LjMuV2UgcmVhZCB0aGUgd29ybGQgd3JvbmcgYW5kIHNheSB0aGF0IGl0IGRlY2VpdmVzIHVzLjQu TGV0IGxpZmUgYmUgYmVhdXRpZnVsIGxpa2Ugc3VtbWVyIGZsb3dlcnMgYW5kIGRlYXRoIGxpa2Ug YXV0dW1uIGxlYXZlcy41LkxldCB0aGlzIGJlIG15IGxhc3Qgd29yZCwgdGhhdCBJIHRydXN0IGlu IHRoeSBsb3ZlLjYuVGhlIGxpdHRsZSBmbG93ZXIgbGllcyBpbiB0aGUgZHVzdC4gSXQgc291Z2h0 IHRoZSBwYXRoIG9mIHRoZSBidXR0ZXJmbHkuNy5MaWZlIGhhcyBiZWNvbWUgcmljaGVyIGJ5IHRo ZSBsb3ZlIHRoYXQgaGFzIGJlZW4gbG9zdC4=

    提示

     对于 30%的数据,n=3,字符串只由字母组成 对于 50%的数据,n=12

    对于 70%的数据,n<=57

    对于 100%的数据,3<=n<=1000

    题解:

    纯暴力,没什么好讲的,注意一下细节就可以了

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<cmath>
    #include<algorithm>
    #include<queue>
    #include<stack>
    #include<ctime>
    #include<vector>
    #define ka (63)
    using namespace std;
    int n,k,cnt;
    char s[3001],ans[3001];
    char t[101]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    void check(int a,int b,int c)
    {
        int m=(a<<16)+(b<<8)+c;
        int d=m&ka;m>>=6;
        c=m&ka;m>>=6;
        b=m&ka;m>>=6;
        a=m&ka;
        ans[cnt++]=t[a];
        ans[cnt++]=t[b];
        ans[cnt++]=t[c];
        ans[cnt++]=t[d];
    }
    int main()
    {
        int i;
        scanf("%d",&n);getchar();
        gets(s+1);
        for(i=1;i<=n;i+=3)
        {
            int a=s[i],b=s[i+1],c=s[i+2];
            check(a,b,c);
        }
        cnt--;
        int j=n%3;
        if(j==1)ans[cnt]=ans[cnt-1]='=';
        if(j==2)ans[cnt]='=';
        int t=0;
        while(1)
        {
            int to=min(cnt,t+76-1);
            for(i=t;i<=to;i++)
                printf("%c",ans[i]);
            printf("
    ");
            t=t+76;
            if(i>=cnt)break;
        }
        return 0;
    }
  • 相关阅读:
    QGIS 编译
    Ubuntu: 无法使用su命令
    win7 与 Ubuntu 16.04 文件传送
    OSGEarth编译
    GADL配置编译
    C++ 类对象和 指针的区别
    C++ Primer Plus 第六版笔记
    Windows下使用doxygen阅读和分析C/C++代码
    _MSC_VER详细介绍
    LUA学习之一 初次接触
  • 原文地址:https://www.cnblogs.com/huangdalaofighting/p/6972072.html
Copyright © 2011-2022 走看看