You are viewing a single comment's thread. Return to all comments →
Hi,
My code works only for the Test Case 0,1,2,3.
My output is:
D(1) = 1, D(2) = 3, D(3) = 7, D(4) = 15, D(5) = 31, D(6) = 63, D(7) = 127, D(8) = 255, D(9) = 511, D(10) = 1023, D(11) = 2047, D(12) = 4095, D(13) = 8191, D(14) = 16383, D(15) = 32767, D(16) = 65535, D(17) = 131071, D(18) = 262143
In this comment (https://www.hackerrank.com/contests/projecteuler/challenges/euler155/forum/comments/194581) says the required output is: 1, 3, 7, 15, 35, 77, 179, 429, 1039, 2525, 6235, 15463, 38513, 96231, 241519, 607339, 1529533, 3857447.
My ouput is lower, I dont have duplicate values.
What is the mistake in my code:
int main(){ int n; cin >> n; double C = 60; set<double> sGlobal; vector< set<double> > vSetValues; vSetValues.push_back(set<double>()); vSetValues[0].insert(C); sGlobal.insert(C); //for(n = 1; n < 19; n++){ for(int i = 1; i < n; i++) { vSetValues.push_back(set<double>()); for(set<double>::iterator ite = vSetValues[i-1].begin(); ite != vSetValues[i-1].end(); ite++) { double serie, parallel; serie = *ite + C; parallel = 1/(1/(*ite) + 1/C); vSetValues[i].insert(serie); vSetValues[i].insert(parallel); sGlobal.insert(serie); sGlobal.insert(parallel); } } //cout << "D(" << n << ") = "; cout << sGlobal.size() <<endl; //} return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #155: Counting Capacitor Circuits.
You are viewing a single comment's thread. Return to all comments →
Hi,
My code works only for the Test Case 0,1,2,3.
My output is:
D(1) = 1, D(2) = 3, D(3) = 7, D(4) = 15, D(5) = 31, D(6) = 63, D(7) = 127, D(8) = 255, D(9) = 511, D(10) = 1023, D(11) = 2047, D(12) = 4095, D(13) = 8191, D(14) = 16383, D(15) = 32767, D(16) = 65535, D(17) = 131071, D(18) = 262143
In this comment (https://www.hackerrank.com/contests/projecteuler/challenges/euler155/forum/comments/194581) says the required output is: 1, 3, 7, 15, 35, 77, 179, 429, 1039, 2525, 6235, 15463, 38513, 96231, 241519, 607339, 1529533, 3857447.
My ouput is lower, I dont have duplicate values.
What is the mistake in my code: