All pastes #935152 Raw Edit

Untitled

public text v1 · immutable
·published 2008-03-09 11:57 UTC
rendered paste body
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

using namespace std;

long long Create (int k , int d)
{
     long long ans = 0 ;
     while (k--)
     {
           ans = ans * 10 + d;
     }
     return ans;     
}

long long pow (int x , int y)
{
     long long ans = 1 ;
     while (y--)
     {
           ans *= x ;      
     }
     return ans;
}

string ToString (long long n)
{
	stringstream t ;
	t << n;
	return t.str();
}

int main()
{
    int t ;
    cin >> t;
    vector <int>ns , ks, ds , ans;
    for (int i = 1; i <=t ; i++)
    {
        int n , k , d ;
        cin>>n>>k>>d;
        ns.push_back(n);
        ks.push_back(k);
        ds.push_back(d);
    }
    for (int i = 0; i < t ;i++)
    {
        int n , k , d ;
        n = ns[i];
        k = ks[i];
        d = ds[i];
        int count = 0 ; 
        int j = Create( k , d) ;
        string t2 = ToString(j);
        while (count < n)
        {
       		j ++ ; 
       		string t  = ToString (j);
       		if (t.find (t2) != -1)
       			count ++;
       		
       	}
        ans.push_back(j);
    }
    
    for (int i = 0 ; i < ans.size() ; i++)
    {
        cout << ans[i]<<endl;    
    }

}