You are viewing a single comment's thread. Return to all comments →
using namespace std;
int main(){ int t; cin >> t; for(int a0 = 0; a0 < t; a0++){ int n, d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0, prod = 0, poli = 0; cin >> n;
for (int i = 100; i <= 999; i++) { for (int j = 100; j <= 999; j++) { prod = i*j; if (prod <= n){ d1 = prod / 100000; d2 = (prod / 10000) % 10; d3 = (prod / 1000) % 10; d4 = (prod / 100) % 10; d5 = (prod / 10) % 10; d6 = prod% 10; } if (d1 == d6 && d2 == d5 && d3 == d4 && prod > poli && prod < n) { poli = prod; } } } cout << poli << endl; } return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #4: Largest palindrome product
You are viewing a single comment's thread. Return to all comments →
include
using namespace std;
int main(){ int t; cin >> t; for(int a0 = 0; a0 < t; a0++){ int n, d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0, prod = 0, poli = 0; cin >> n;
}