От: | Evgeny.Panasyuk | ||
Дата: | 30.10.15 09:33 | ||
Оценка: | 58 (7) |
#include <iostream>
bool fermat()
{
constexpr int threshold = 100;
int a = 1, b = 1, c = 1;
while(true)
{
if( a*a*a + b*b*b == c*c*c )
return true;
++a;
if(a > threshold)
{
a = 1;
++b;
}
if(b > threshold)
{
b = 1;
++c;
}
if(c > threshold)
c = 1;
}
return false;
}
int main()
{
using namespace std;
cout << boolalpha << fermat() << endl;
}
clang++ -std=c++1z -O3 -Wall main.cpp && ./a.out
true