Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
114578 | 彭士宝 | 美丽数 | C++ | Time Limit Exceeded | 1000 MS | 1180 KB | 727 | 2025-03-22 17:23:01 |
#include <iostream> #include <vector> using namespace std; int main() { // 预处理前100000个美丽数 vector<int> beautifulNumbers; int count = 0; int i3 = 3, i5 = 5; while (count < 100000) { if (i3 < i5) { beautifulNumbers.push_back(i3); i3 += 3; } else if (i5 < i3) { beautifulNumbers.push_back(i5); i5 += 5; } else { beautifulNumbers.push_back(i3); i3 += 3; i5 += 5; } count++; } // 处理多组输入 int N; while (cin >> N) { cout << beautifulNumbers[N - 1] << endl; // 输出第N个美丽数 } return 0; }