QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#51611#4634. FactorHongzyRE 0ms0kbC++1.1kb2022-10-02 23:41:572022-10-02 23:41:59

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-02 23:41:59]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2022-10-02 23:41:57]
  • 提交

answer

#include <bits/stdc++.h>
#define LOG(FMT...) fprintf(stderr, FMT);
#define rep(i, j, k) for(int i = j; i <= k; ++ i)
#define per(i, j, k) for(int i = j; i >= k; -- i)
using namespace std;
typedef long long ll;
const int N = 3e6 + 10;
bool tag[N];
int p[N], pc, s[N];
void sieve(int n) {
  rep(i, 2, n) {
    if(!tag[i]) p[++ pc] = i;
    s[i] = s[i-1] + (!tag[i]);
    for(int j = 1; j <= pc && i * p[j] <= n; j ++) {
      tag[i * p[j]] = 1;
      if(i % p[j] == 0) break ;
    }
  }
}
int range(int x, int y) {
  return x > y ? 0 : s[y] - s[x-1];
}
ll n, ans = 1;
void dfs(ll x, ll s, int id) {
  for(int i = id + 1; p[i] <= s+1 && x * p[i] <= n; i ++) {
    if(x * p[i] * p[i] > n) {
      ans += range(p[i], min(s+1, n / x));
      break;
    }
    ans++;
    ll z = 1, s0 = 1;
    rep(j, 1, 50) {
      z *= p[i], s0 += z;
      if(x * z > n) break;
      dfs(x * z, s * s0, i);
      if(j >= 2)
        ++ans;
    }
  }
}
int main() {
  sieve(5e6);
  scanf("%lld", &n);
  dfs(1, 1, 0);
  printf("%lld\n", ans);
  return 0;
}

详细

Test #1:

score: 0
Runtime Error

input:

10

output:


result: