循环处理3个案例的最快方法

We have integers X, Y and Z. We should find (x, y, z), where x * z > y^2 with the following constraints: 0 < x <= X, 0 < y <= Y and 0 < z <= Z as well as 1 <= X, Y, Z <= 1000.

循环可能不是最佳解决方案。寻找明智的表现。

#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

int main() 
{
    string s;
    getline(cin, s); // 2 3 4

    std::istringstream iss(s);
    std::vector<int> v((std::istream_iterator<int>(iss)), std::istream_iterator<int>());

    int X = v[0];
    int Y = v[1];
    int Z = v[2];

    return 0;
}
评论