/*
ID:18861501
LANG:C++
TASK:palsquare
*/
/*------------------Header Files------------------*/
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <ctype.h>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <limits.h>
using namespace std;
/*------------------Definitions-------------------*/
#define LL long long
#define PI acos(-1.0)
#define INF 0x3F3F3F3F
/*---------------------Work-----------------------*/
int s[100],t[100];
bool is_hui(int *s,int cnt)
{
for(int i=1;i<=cnt/2;i++)
if(s[i]!=s[cnt-i+1]) return false;
return true;
}
void print(int *s,int cnt)
{
for(int i=cnt;i>=1;i--)
{
if(s[i]>=0&&s[i]<=9) printf("%d",s[i]);
else if(s[i]==10) printf("A");
else if(s[i]==11) printf("B");
else if(s[i]==12) printf("C");
else if(s[i]==13) printf("D");
else if(s[i]==14) printf("E");
else if(s[i]==15) printf("F");
else if(s[i]==16) printf("G");
else if(s[i]==17) printf("H");
else if(s[i]==18) printf("I");
else if(s[i]==19) printf("J");
}
}
void work()
{
int base;
scanf("%d",&base);
for(int num=1;num<=300;num++)
{
int cnt1=1,cnt2=1,n=num;
while(n)
{
s[cnt1++]=n%base;
n=n/base;
}
cnt1--;
n=num*num;
while(n)
{
t[cnt2++]=n%base;
n=n/base;
}
cnt2--;
if(is_hui(t,cnt2))
{
print(s,cnt1);
printf(" ");
print(t,cnt2);
printf("\n");
}
}
}
/*------------------Main Function------------------*/
int main()
{
//freopen("test.txt","r",stdin);
freopen("palsquare.out","w",stdout);
freopen("palsquare.in","r",stdin);
work();
return 0;
}
1.2.4
最新推荐文章于 2021-03-06 02:35:43 发布