1 条题解
-
0
AC
#include <iostream> #include <string> #include <algorithm> bool hasUniqueDigits(const std::string& num) { std::string sortedNum = num; std::sort(sortedNum.begin(), sortedNum.end()); for (size_t i = 1; i < sortedNum.size(); ++i) { if (sortedNum[i] == sortedNum[i - 1]) { return false; } } return true; } int main() { for (int a = 123; a <= 333; ++a) { int b = 3 * a; int c = 5 * a; std::string strA = std::to_string(a); std::string strB = std::to_string(b); std::string strC = std::to_string(c); if (strA.length() == 3 && strB.length() == 3 && strC.length() == 3) { std::string combined = strA + strB + strC; if (combined.length() == 9 && hasUniqueDigits(combined)) { std::cout << b << std::endl; return 0; } } } std::cout << "No solution found" << std::endl; return 0; }
- 1
信息
- ID
- 739
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 5
- 标签
- 递交数
- 117
- 已通过
- 41
- 上传者