Can someone give me a tricky test case and output of the problem
i am getting WA. Thanks in advance
there is my code :
/******** In the name of Allah, the most gracious, the most merciful ********/
#include <bits/stdc++.h>
using namespace std;
#define Max 10000001
int phi[10000001],ans[10000001];
bool Permutation(int a,int b)
{
if((a-b)%9)
return false;
string s1 = to_string(a),s2 = to_string(b);
sort(s1.begin(),s1.end());
sort(s2.begin(),s2.end());
return (s1==s2);
}
void sieve_phi()
{
phi[1] = 1;
for(int i=2;i<=Max;i++)
{
if(!phi[i])
{
phi[i] = i-1;
for(int j = i2;j <= Max;j += i)
{
if(!phi[j])
phi[j] = j;
phi[j] = (phi[j]/i)(i-1);
}
}
}
for(int i=2;i<=20;i++)
ans[i]=-1;
ans[21] = 21;
for(int i=22;i<=Max;i++)
{
if(Permutation(i,phi[i]))
{
if(ans[i-1]/phi[ans[i-1]]>=i/phi[i])
{
ans[i]=i;
}
else
ans[i] = ans[i-1];
}
else
ans[i] = ans[i-1];
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
sieve_phi();
int n,t;
scanf("%d",&t);
while(t–)
{
scanf("%d",&n);
if(ans[n]==-1)
printf(“No solution.\n”);
else
printf("%d\n",ans[n]);
}
}