#include <iostream>
#include <map>
typedef std::map<double, std::pair<int, int>> DType;
DType MakeHoge(std::size_t M){
DType R;
double D = 0;
for (std::size_t i = 2; i <= M; i++){
for (std::size_t j = 1; j < i; j++){
auto P = std::make_pair(j, i);
D = j / static_cast<double>(i);
if (D >= 1) continue;
auto it = R.find(D);
if (it == R.end()) R[D] = P;
}
}
return R;
}
bool Show(DType M){
for (auto& o : M)std::cout << o.second.first << '/' << o.second.second << '=' << o.first << std::endl;
return true;
}
int main(){
DType R;
std::cout << "M == 3" << std::endl;
R = MakeHoge(3);
Show(R);
std::cout << "M == 5" << std::endl;
R = MakeHoge(5);
Show(R);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWFwPgoKdHlwZWRlZiBzdGQ6Om1hcDxkb3VibGUsIHN0ZDo6cGFpcjxpbnQsIGludD4+IERUeXBlOwoKRFR5cGUgTWFrZUhvZ2Uoc3RkOjpzaXplX3QgTSl7CglEVHlwZSBSOwoJZG91YmxlIEQgPSAwOwoJZm9yIChzdGQ6OnNpemVfdCBpID0gMjsgaSA8PSBNOyBpKyspewoJCWZvciAoc3RkOjpzaXplX3QgaiA9IDE7IGogPCBpOyBqKyspewoJCQlhdXRvIFAgPSBzdGQ6Om1ha2VfcGFpcihqLCBpKTsKCQkJRCA9IGogLyBzdGF0aWNfY2FzdDxkb3VibGU+KGkpOwoJCQlpZiAoRCA+PSAxKSBjb250aW51ZTsKCQkJYXV0byBpdCA9IFIuZmluZChEKTsKCQkJaWYgKGl0ID09IFIuZW5kKCkpIFJbRF0gPSBQOwoJCX0KCX0KCglyZXR1cm4gUjsKCn0KCmJvb2wgU2hvdyhEVHlwZSBNKXsKCglmb3IgKGF1dG8mIG8gOiBNKXN0ZDo6Y291dCA8PCBvLnNlY29uZC5maXJzdCA8PCAnLycgPDwgby5zZWNvbmQuc2Vjb25kIDw8ICc9JyA8PCBvLmZpcnN0IDw8IHN0ZDo6ZW5kbDsKCXJldHVybiB0cnVlOwp9CgppbnQgbWFpbigpewoKCURUeXBlIFI7CgkKCXN0ZDo6Y291dCA8PCAiTSA9PSAzIiA8PCBzdGQ6OmVuZGw7CglSID0gTWFrZUhvZ2UoMyk7CglTaG93KFIpOwoJc3RkOjpjb3V0IDw8ICJNID09IDUiIDw8IHN0ZDo6ZW5kbDsKCVIgPSBNYWtlSG9nZSg1KTsKCVNob3coUik7CgkKCXJldHVybiAwOwoKfQ==