fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long LL;
  6.  
  7. const LL MOD = 1e9 + 7;
  8.  
  9. int greatest_divisor(int n)
  10. {
  11. for(int i = 2; i * i <= n; i++)
  12. {
  13. if(n % i == 0)
  14. {
  15. return n / i;
  16. }
  17. }
  18.  
  19. return 1;
  20. }
  21.  
  22. int calculate_game(LL n)
  23. {
  24. LL ret = (n * (n - 1)) / 2;
  25. return ret % MOD;
  26. }
  27.  
  28. int main()
  29. {
  30. ios_base::sync_with_stdio(false);
  31. cin.tie(NULL);
  32.  
  33. int t;
  34.  
  35. cin>>t;
  36.  
  37. while(t--)
  38. {
  39. int n;
  40. LL match = 0;
  41.  
  42. cin>>n;
  43.  
  44. while(n > 1)
  45. {
  46. LL group = greatest_divisor(n);
  47. LL team = n / group;
  48. match = (match + ((group * calculate_game(team)) % MOD)) % MOD;
  49. n = group;
  50. }
  51.  
  52. cout<<match<<endl;
  53. }
  54.  
  55. return 0;
  56. }
  57.  
Success #stdin #stdout 0.01s 5420KB
stdin
3
5
10
20
stdout
10
15
25