fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int t;
  7. cin>>t;
  8. while(t--)
  9. {
  10. int x;
  11. cin>>x;
  12. int a[x+1];
  13. int b;
  14. a[0]=0;
  15. a[1]=1;
  16. for(int i=1;i<=x;i++)
  17. {
  18. int arr[x+1]={0};
  19. arr[1]=1;
  20. for(int j=2;j<=i;j++)
  21. {
  22. if(arr[j]==0)
  23. {
  24. for(int k=j;k<=i;k+=j)
  25. {
  26.  
  27. arr[k]=j;
  28. b=k;
  29. }
  30. }
  31. }
  32.  
  33. a[i]=a[i-1]+arr[b];
  34.  
  35.  
  36. }
  37. cout<<a[x]<<endl;
  38. }
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0s 15240KB
stdin
4
1
2
3
4
stdout
0
2
5
8