Untitled

mail@pastecode.io avatar
unknown
plain_text
4 years ago
421 B
4
Indexable
Never
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	long long n,i,a[1000],j,k;
	cin >> t;
	while(t--)
	{	
		cin >> n >> k;
		j=1;
		for(i=2;i<=sqrt(n);i++)
		{
			while(n%i==0)
			{
				a[j]=i;
				j++;
				n=n/i;	
			}	
		}
		if(n!=1) { a[j]=n; j++;  } 
		else j--;
	
	if(k<j) cout << a[k] << " ";
		else cout <<"-1";
		cout << endl;		
		}
 	return 0;
}