Guangdong freshman season m

Here Insert Picture Description

Feeling okay relatively solid can be considered a relatively simple question
is to find a periodic law
but the number is large
so I used the same
string realize
I was also constructed auxiliary character array subscript easy to find
my code a little bit a waste of time because the length of know I gave forget again
have little effect

Rush

#include<bits/stdc++.h>
using namespace std;
char s[35],temp[35],m[10000];
int main()
{
	int n;
	scanf("%d%s",&n,m);
	scanf("%s",s);
	int len=strlen(s);
	int t=2*len;
	int lenth=strlen(m);
	int ans=0,cnt=0;
	for(int i=0;i<lenth;i++)
		ans=(ans*10+m[i]-'0')%t;
	for(int i=0;i<len;i++)
		temp[cnt++]=s[i];
	for(int j=len-1;j>=0;j--)
		temp[cnt++]=s[j];
	if(!ans)
		printf("%c\n",temp[cnt-1]);
	else
		printf("%c\n",temp[ans-1]);
	return 0;
}
Published 54 original articles · won praise 4 · Views 884

Guess you like

Origin blog.csdn.net/weixin_45460987/article/details/103442197