We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<iostream>#include<vector>//#define ORIGINALintmain(){#ifdef ORIGINALunsignedintlimit=1000000;// "less than one million"#elseunsignedintlimit=8000001;// up to 8 million (inclusive)#endif// precompute solutionsstd::vector<unsignedint>solutions(limit,0);for(unsignedinta=1;a<limit;a++)for(autob=(a+3)/4;b<a;b++){autocurrent=a*(4*b-a);if(current>=limit)break;solutions[current]++;}#ifdef ORIGINAL// count all with exactly 10 solutionsunsignedintcount=0;for(autos:solutions)if(s==10)count++;std::cout<<count<<std::endl;#else// look up number of solutionsunsignedinttests;std::cin>>tests;while(tests--){unsignedintpos;std::cin>>pos;std::cout<<solutions[pos]<<std::endl;}#endifreturn0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #135: Same differences
You are viewing a single comment's thread. Return to all comments →
100/- Points C++