门(door)

门(door)

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

题目描述

门(door)

门(door)

输入

第一行是一个正整数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[],ans[];
char t[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
void check(int a,int b,int c)
{
int m=(a<<)+(b<<)+c;
int d=m&ka;m>>=;
c=m&ka;m>>=;
b=m&ka;m>>=;
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+);
for(i=;i<=n;i+=)
{
int a=s[i],b=s[i+],c=s[i+];
check(a,b,c);
}
cnt--;
int j=n%;
if(j==)ans[cnt]=ans[cnt-]='=';
if(j==)ans[cnt]='=';
int t=;
while()
{
int to=min(cnt,t+-);
for(i=t;i<=to;i++)
printf("%c",ans[i]);
printf("\n");
t=t+;
if(i>=cnt)break;
}
return ;
}
上一篇:C# oracle 参数传递的多种方式 留着复习


下一篇:详解python之反射机制