首页 > 代码库 > hdu 5019
hdu 5019
#include <iostream> #include <fstream> #include <vector> #include <cstdio> #include <string> #include <cstring> #include <cstdlib> #include <algorithm> #include <cmath> #include <cfloat> #include <stack> #include <set> using namespace std; #ifdef DEBUG ifstream in; ofstream out; #endif #ifdef DEBUG #define CIN in #define COUT out #else #define CIN cin #define COUT cout #endif typedef long long int ll; ll x, y, idx, tmp, val, last; int cases; vector<ll> store; int main(void) { #ifdef DEBUG string buffer; CIN.open("in", ios::in); COUT.open("out", ios::out); while(getline(CIN, buffer)) COUT << buffer << "\n"; COUT << "Out Put" << "\n"; CIN.close(); CIN.open("in", ios::in); #endif CIN >> cases; for(int caseCurr = 1; caseCurr <= cases; caseCurr++){ CIN >> x >> y >> idx; store.clear(); while(y){ tmp = x%y; x = y; y = tmp; } last = (ll)(sqrt((1.0)*x) + 0.5); for(val = 1; val <= last; val++){ if(0 == x%val){ store.push_back(val); if(val*val != x){ store.push_back(x/val); } } } if(idx > (ll)store.size()){ COUT << "-1" << endl; }else{ sort(store.begin(), store.end()); COUT << store[store.size() - idx] << endl; } } return 0; }
hdu 5019
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。