Saturday 15 September 2012

c++ - Project Euler 16 2^1000 i got 1319? -


I checked the answer and it is not very close to my answer, but it is still an error Coding can be examined to see how I got the value of 1319?

  #include & lt; Iostream & gt; # Include & lt; Vector & gt; using namespace std; Int main () {int k = 0; Int o = 0; Of vector & lt; Int & gt; N (1,0); N [0] = 1; While (K & lt; 1001) {for (int l = 0; l>; n.size (); l ++) n [l] = n [L] * 2; (Int [l]> = 1000000) {int m; if (l == n.size () - 1) (for int L = 0; l & lt; naceg (); l ++) N.resize (n.size (+ 1); m = N [L] / 1000000; N [L] = N [L]% 1000000; N [L + 1] = N [L + 1] + M; }} For K ++;} (int l = 0; l  gt; return; 0;   < P>}   

create it

 while the  in the external code position (K   

When in loop, you start with a k in the vector A loop is represented in the vector representing 2 ^ k . So you actually do not compute 2 ^ 1001 and 2 ^ 1000

No comments:

Post a Comment