Advertisement
Saleh127

UVA 10408

Mar 16th, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. vector<pair<double,pair<ll,ll>>>x;
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);
  10. cout.tie(0);
  11.  
  12. ll n,m,i,j,k,l;
  13.  
  14. while(cin>>n>>k)
  15. {
  16. x.clear();
  17.  
  18. x.push_back(make_pair(1.00,make_pair(1,1)));
  19.  
  20. ///x.push_back({1.00,{1,1}});
  21.  
  22. for(i=1; i<=n; i++)
  23. {
  24. for(j=i+1; j<=n; j++)
  25. {
  26. if(__gcd(i,j)!=1)
  27. {
  28. continue;
  29. }
  30. else
  31. {
  32. x.push_back(make_pair((double)i/j,make_pair(i,j)));
  33. ///x.push_back({(double)i/j,{i,j}});
  34. }
  35. }
  36. }
  37. sort(x.begin(),x.end());
  38.  
  39. cout<<x[k-1].second.first<<"/"<<x[k-1].second.second<<endl;
  40.  
  41. }
  42.  
  43.  
  44. return 0;
  45. }
  46.  
  47.  
  48. /*
  49. #include <bits/stdc++.h>
  50. using namespace std;
  51. #define ll long long
  52. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  53. vector<pair<double,pair<ll,ll>>>x;
  54. int main()
  55. {
  56. ios_base::sync_with_stdio(0);
  57. cin.tie(0);
  58. cout.tie(0);
  59.  
  60. ll n,m,i,j,k,l;
  61.  
  62. while(cin>>n>>k)
  63. {
  64. x.clear();
  65.  
  66. x.emplace_back(1.00,make_pair(1,1));
  67.  
  68. for(i=1; i<=n; i++)
  69. {
  70. for(j=i+1; j<=n; j++)
  71. {
  72. if(__gcd(i,j)!=1)
  73. {
  74. continue;
  75. }
  76. else
  77. {
  78. x.emplace_back((double)i/j,make_pair(i,j));
  79. }
  80. }
  81. }
  82. sort(x.begin(),x.end());
  83.  
  84. cout<<x[k-1].second.first<<"/"<<x[k-1].second.second<<endl;
  85.  
  86. }
  87.  
  88.  
  89. return 0;
  90. }
  91. */
  92.  
  93. /*
  94. #include <bits/stdc++.h>
  95. using namespace std;
  96. #define ll long long
  97. bool cmp(pair<ll,ll>a,pair<ll,ll>b)
  98. {
  99. double c=(double)a.first/a.second;
  100. double d=(double)b.first/b.second;
  101.  
  102. return c<d;
  103. }
  104.  
  105. int main()
  106. {
  107. ios_base::sync_with_stdio(0);
  108. cin.tie(0);
  109. cout.tie(0);
  110.  
  111. ll n,m,i,j,k,l;
  112.  
  113. while(cin>>n>>k)
  114. {
  115. vector<pair<ll,ll>>x;
  116.  
  117. x.push_back({1,1});
  118.  
  119. for(i=1; i<=n; i++)
  120. {
  121. for(j=i+1; j<=n; j++)
  122. {
  123. if(__gcd(i,j)!=1)
  124. {
  125. continue;
  126. }
  127. else
  128. {
  129. x.push_back(make_pair(i,j));
  130. }
  131. }
  132. }
  133. sort(x.begin(),x.end(),cmp);
  134.  
  135. cout<<x[k-1].first<<"/"<<x[k-1].second<<endl;
  136.  
  137. }
  138.  
  139.  
  140. return 0;
  141. }
  142. */
  143.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement