fork download
  1. #include <iostream>
  2. #include <tuple>
  3. #include <vector>
  4. #include <cstdint>
  5. #include <algorithm>
  6.  
  7. typedef std::tuple<std::uint64_t, std::uint64_t> Tup;
  8. typedef std::vector<Tup> RType;
  9.  
  10. RType MakeHoge(std::uint64_t All, std::uint64_t A, std::uint64_t B){
  11. std::uint64_t Max = std::max(All / A, All / B) + 1;
  12. RType R;
  13.  
  14. for (std::uint64_t i = 0; i < Max; i++){
  15. for (std::uint64_t j = 0; j < Max-i; j++){
  16. if (All - (A*i + B*j) == 0) R.push_back(std::make_tuple(i, j));
  17. }
  18. }
  19.  
  20. return R;
  21. }
  22.  
  23. bool Show(RType R, std::uint64_t A, std::uint64_t B){
  24. std::uint64_t X, Y;
  25. for (auto& o : R){
  26. std::tie(X, Y) = o;
  27. double V = A*X + B*Y;
  28. std::cout << X << "," << Y << "->"<< V <<"("<<(A*X)/V*100<<","<<(B*Y)/V*100<<")"<< std::endl;
  29. }
  30. std::cout <<"Dump Done!"<< std::endl;
  31. return true;
  32. }
  33.  
  34. int main(){
  35. std::uint64_t All = 462300;
  36. std::uint64_t A = 1500;
  37. std::uint64_t B = 700;
  38.  
  39. auto R = MakeHoge(All, A, B);
  40. Show(R, A, B);
  41.  
  42. return 0;
  43. }
Success #stdin #stdout 0s 3276KB
stdin
Standard input is empty
stdout
3,654->462300(0.973394,99.0266)
10,639->462300(3.24465,96.7554)
17,624->462300(5.5159,94.4841)
24,609->462300(7.78715,92.2128)
31,594->462300(10.0584,89.9416)
38,579->462300(12.3297,87.6703)
45,564->462300(14.6009,85.3991)
52,549->462300(16.8722,83.1278)
59,534->462300(19.1434,80.8566)
66,519->462300(21.4147,78.5853)
73,504->462300(23.6859,76.3141)
80,489->462300(25.9572,74.0428)
87,474->462300(28.2284,71.7716)
94,459->462300(30.4997,69.5003)
101,444->462300(32.7709,67.2291)
108,429->462300(35.0422,64.9578)
115,414->462300(37.3134,62.6866)
122,399->462300(39.5847,60.4153)
129,384->462300(41.8559,58.1441)
136,369->462300(44.1272,55.8728)
143,354->462300(46.3984,53.6016)
150,339->462300(48.6697,51.3303)
157,324->462300(50.9409,49.0591)
164,309->462300(53.2122,46.7878)
171,294->462300(55.4835,44.5165)
178,279->462300(57.7547,42.2453)
185,264->462300(60.026,39.974)
192,249->462300(62.2972,37.7028)
199,234->462300(64.5685,35.4315)
206,219->462300(66.8397,33.1603)
213,204->462300(69.111,30.889)
220,189->462300(71.3822,28.6178)
227,174->462300(73.6535,26.3465)
234,159->462300(75.9247,24.0753)
241,144->462300(78.196,21.804)
248,129->462300(80.4672,19.5328)
255,114->462300(82.7385,17.2615)
262,99->462300(85.0097,14.9903)
269,84->462300(87.281,12.719)
276,69->462300(89.5522,10.4478)
283,54->462300(91.8235,8.17651)
290,39->462300(94.0947,5.90526)
297,24->462300(96.366,3.634)
304,9->462300(98.6372,1.36275)
Dump Done!