Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main(){
- int numbers[28123];
- int sindex, cindex = 0;
- for(sindex = 0; sindex < 28123; sindex++)
- numbers[sindex] = 0 - (sindex + 1);
- sindex = 0;
- while(sindex < (int)sqrt(28123)){
- if(cindex >= 28123){
- sindex++;
- cindex = (sindex + 1) * 2 - 1;
- }
- if(sindex + 1 <= (int)sqrt(cindex + 1))
- numbers[cindex] += (sindex + 1) + ((cindex + 1) / (sindex + 1) == (sindex + 1) ? 0: (cindex + 1) / (sindex + 1));
- cindex += sindex + 1;
- }
- cindex = 0;
- for(sindex = 0; sindex < 28123; sindex++)
- if(numbers[sindex] > sindex + 1)
- cindex++;
- int abundants[cindex];
- for(sindex = 0, cindex = 0; sindex < 28123; sindex++)
- if(numbers[sindex] > sindex + 1){
- abundants[cindex] = sindex + 1;
- cindex++;
- }
- sindex = cindex = 0;
- while(sindex < sizeof(abundants) / sizeof(abundants[0])){
- if(cindex >= sizeof(abundants) / sizeof(abundants[0]) || abundants[sindex] + abundants[cindex] - 1 >= 28123){
- sindex++;
- cindex = sindex;
- }
- else{
- numbers[abundants[sindex] + abundants[cindex] - 1] = -1;
- cindex++;
- }
- }
- for(sindex = 0, cindex = 0; sindex < 28123; sindex++)
- if(numbers[sindex] != -1)
- cindex += sindex + 1;
- cout<< cindex << endl;
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment