fork(4) download
  1. #include <bits/stdc++.h>
  2.  
  3. #define INF 100000000
  4. #define MOD 1000000007
  5. #define MAXN 100005
  6. #define ins insert
  7. #define pb push_back
  8. #define mp make_pair
  9. #define sz size
  10. #define sd(n) scanf("%d",&n)
  11. #define pdn(n) printf("%d\n",n)
  12. #define pd(n) printf("%d ",n)
  13. #define nl() printf("\n")
  14. using namespace std;
  15.  
  16. typedef long long ll;
  17. typedef unsigned long long ull;
  18. typedef vector<int> vi;
  19. typedef vector<vi> vii;
  20. typedef pair<int, int> pii;
  21.  
  22. vi primes;
  23.  
  24. bool check[MAXN];
  25.  
  26. int main() {
  27. //clock_t start=clock();
  28. for (int i = 3; i*i <= 31623; i += 2) {
  29. if (!check[i]) {
  30. for (int j = i*i; j <= 31623; j += i)
  31. check[j] = true;
  32. }
  33. }
  34. primes.pb(2);
  35. for (int i = 3; i <= 31623; i += 2)
  36. if (!check[i])
  37. primes.pb(i);
  38. int lim = primes.sz();
  39. int a, b, n; sd(a), sd(b), sd(n);
  40. int countt = 0; //final answer
  41. for (int i = a; i <= b; ++i) {
  42. int x = 1; //Count of divisors of i
  43. int temp = i;
  44. for (int j = 0; (primes[j]*primes[j] <= i) && (j < lim); ++j) {
  45. if (!(temp % primes[j])) {
  46. int cc = 0;
  47. while (!(temp % primes[j])) {
  48. temp /= primes[j];
  49. cc++;
  50. }
  51. x *= (cc+1);
  52. if (x > n)
  53. break;
  54. }
  55. }
  56. if (temp != 1)
  57. x *= 2;
  58. if (x == n)
  59. ++countt;
  60. }
  61. pdn(countt);
  62. //clock_t stop=clock();
  63. //double elapsed=(double)(stop-start) * 1000.0 / CLOCKS_PER_SEC;
  64. //printf("Time elapsed in ms : %f",elapsed);
  65. return 0;
  66. }
Success #stdin #stdout 0s 3572KB
stdin
Standard input is empty
stdout
0