QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#298141#4634. Factordefyers#Compile Error//C++141.0kb2024-01-05 18:30:272024-01-05 18:30:27

Judging History

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

  • [2024-01-05 18:30:27]
  • 评测
  • [2024-01-05 18:30:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define LL long long

vector<int> prime;
void find_prime(int n) {
    vector<int> lp(n, 0);
    for (int i = 2; i <= n; i++) {
        if (lp[i] == 0) { lp[i] = i; prime.push_back(i); }
        for (int j = 0; i * prime[j] <= n; j++) {
            lp[i * prime[j]] = prime[j];
            if (prime[j] == lp[i]) break; } } return;
}

LL n;
LL ans = 0;

f(LL sum, LL num, int pl) {
	ans++;
	//cout << "num=" << num << endl;
	for (int i = pl; i < prime.size(); i++) {
		if (prime[i] * num > n || sum + 1 < prime[i]) break;
		LL tmp = prime[i];
		LL add = 1 + prime[i];
		while (tmp * num <= n) {
			f(min((LL)1e7, sum * add), tmp * num, i + 1);
			tmp *= prime[i];
			add += tmp;
			add = min(add, (LL)1e7);
		}
	}
}

void solve() {
	cin >> n;
	f(1, 1, 0); // prime[0] = 2
	cout << ans << "\n";
	return;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
   	cout << fixed << setprecision(10);
	find_prime(3e6);
	solve();
	return 0;
}

详细

answer.code:18:1: error: ISO C++ forbids declaration of ‘f’ with no type [-fpermissive]
   18 | f(LL sum, LL num, int pl) {
      | ^
answer.code: In function ‘int f(long long int, long long int, int)’:
answer.code:32:1: warning: no return statement in function returning non-void [-Wreturn-type]
   32 | }
      | ^