fork download
  1. #include <iostream>
  2. #include <queue>
  3.  
  4. using namespace std;
  5.  
  6. #define ll long long
  7. #define pb push_back
  8. #define fi first
  9. #define se second
  10.  
  11. const ll MAXN = 1e4 + 5;
  12. const ll MOD = 1e9 + 7;
  13. const ll INF = 1e9 + 7;
  14.  
  15. void FastIO(){
  16. ios_base::sync_with_stdio(false);
  17. cin.tie(NULL); cout.tie(NULL);
  18. }
  19.  
  20. void fre(){
  21. freopen("CAU1.inp", "r", stdin);
  22. freopen("CAU1.out", "w", stdout);
  23. }
  24.  
  25. ll n, check[MAXN]{}, cnt = 0;
  26. queue<ll> q;
  27.  
  28. int main()
  29. {
  30. FastIO();
  31. fre();
  32. cin >> n;
  33. q.push(n);
  34. check[n] = 1;
  35. while(!q.empty()){
  36. ll k = q.front();
  37. q.pop();
  38. for(int i=1; i*i<=k; ++i)
  39. if(k % i == 0){
  40. ll tmp = (i - 1) * (k/i + 1);
  41. if(check[tmp] == 0){
  42. ++cnt;
  43. check[tmp] = 1;
  44. q.push(tmp);
  45. }
  46. }
  47. }
  48. cout << cnt;
  49. return 0;
  50. }
  51.  
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
Standard output is empty