/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
// 2/13/23
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n = 256;
string vals[n];
int count = 0;
for (int r = 0; r < n; r++) {
for (int i = 0; i < n; i++) {
for (int j = 0; j<n; j++) {
count++;
if ( (i*i + j*j)%n == r) {
vals[r] = "" + to_string(i) + "^2 + " + to_string(j) + "^2 (mod " + to_string(n) + ")";
break;
}
}
if (vals[r] != "") {
break;
}
}
}
int countbad = 0;
string bads = "Numbers that aren't the sum of 2 squares (mod " + to_string(n) + "): ";
for (int i = 0; i < n; i++) {
cout << i << " = " << vals[i] << endl;
if (vals[i] == "") {
countbad++;
bads += to_string(i) + " ";
}
}
cout << bads << endl;
cout << "A total of this many bad/impossible numbers: " << countbad << endl;
cout << "Went through this many loops: " << count << endl;
return 0;
}