Skip to content

Instantly share code, notes, and snippets.

@08vivek08
Created June 8, 2019 18:27
Show Gist options
  • Save 08vivek08/fe0041c725d9b57ced5a91b8fcc3ec2f to your computer and use it in GitHub Desktop.
Save 08vivek08/fe0041c725d9b57ced5a91b8fcc3ec2f to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll large=1000000007;
bool distinct(ll i,ll k)
{
set<ll>s;
while(i>0)
{
s.insert(i%10);
if(s.size()>2)
{
return false;
}
i/=10;
}
if(i==0)
{
while(k>0)
{
s.insert(k%10);
if(s.size()>2)
{
return false;
}
k/=10;
}
if(k==0 && s.size()==2){
return true;
}
}
return false;
}
int main() {
// your code goes here
ll t;
cin>>t;
while(t--)
{
ll k,n=0;
cin>>k;
ll l=pow(10,k)-1;
for(ll i=0;i<=l/2;i=i+1)
{
if(distinct(i,l-i)==true)
{
n=n+2;
}
}
ll ans=(n+2)%large;
cout<<ans<<"\n";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment