#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include // Site: www.hackerrank.com // Competition: World Code Sprint 12 // Problem: Breaking Sticks // Problem Code: Problem 3 // by lboris /* */ typedef unsigned int uint; typedef unsigned long long llu; typedef long long int lls; #define f(i,s,e) for(int i=s;i<(int)(e);++i) #define fe(i,s,e) for(int i=s;i<=(int)(e);++i) #define fi(i,s,e,d) for(unsigned int i=s;in) break; fie(j, (int)k, (uint)n, i) { iPrimes[j] = 0; } } } lPrimes = new int[pn]; fe(i, 2, n) { if (iPrimes[i] > 0) { lPrimes[lPrimesNum] = i; llu x = (llu)i*i; if (x < n) { for (int k = (int)x; k <= n; k += (int)x) { iPrimes[k] -= 1; } } lPrimesNum++; } } } int get_divs(llu n, llu * divs, int * pows) { int nn = 0; int i = 0; while (i