#include<stdio.h>
#include <stdlib.h>
void sortwithweight(int gh[],int g[],int n)
{
for(int i=0;i<n;i++)
{
for(int j=0;j<n-i-1;j++)
{
if(g[j]>g[j+1])
{
int t1=g[j];
g[j]=g[j+1];
g[j+1]=t1;
int t2=gh[j];
gh[j]=gh[j+1];
gh[j+1]=t2;
}
}
}
}
int isperfect(int k){
return (sqrt(k)-floor(sqrt(k))==0);
}
int main()
{
int N;
scanf("%d", &N);
int gh[N],g[N];
for(int i=0;i< N;i++){
scanf("%d ",&gh[i]);
g[i]=0;
if(isperfect(gh[i]))
g[i]+=5;
if(gh[i]%4==0 && gh[i]%6==0)
g[i]+=4;
if(gh[i]%2==0)
g[i]+=3;
}
sortwithweight(gh,g,N);
for(int i=0;i<N;i++)
printf("%d %d\n",gh[i],g[i]);
}
Subscribe to:
Posts (Atom)
Just Give Your Feedback ConversionConversion EmoticonEmoticon