QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#714913 | #4634. Factor | Kevin5307 | AC ✓ | 1306ms | 39064kb | C++20 | 1.5kb | 2024-11-06 09:09:42 | 2024-11-06 09:09:43 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
const int thres=4e6;
int isp[thres+5];
int psum[thres+5];
ll pr[thres+5];
int tot;
ll n;
ll dfs(int cur,ll C,ll S)
{
if(pr[cur]*pr[cur]>n/C) return 0;
if(pr[cur]>S+1) return 0;
ll val=1;
ll ans=0;
for(int i=0;;i++)
{
ans+=dfs(cur+1,C,min(S*val,n));
if(i>=1&&min(S*val+1,n/C)>pr[cur])
ans+=psum[min(S*val+1,n/C)]-psum[pr[cur]];
if(i>=2)
ans++;
if(C*pr[cur]>n) break;
C*=pr[cur];
val=val*pr[cur]+1;
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
for(int i=2;i<=thres;i++)
isp[i]=1;
for(int i=2;i<=thres;i++)
for(int j=i+i;j<=thres;j+=i)
isp[j]=0;
for(int i=2;i<=thres;i++)
psum[i]=psum[i-1]+isp[i];
for(int i=2;i<=thres;i++)
if(isp[i])
pr[++tot]=i;
cin>>n;
cout<<dfs(1,1,1)+1+(n>1)<<endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 127ms
memory: 37364kb
input:
10
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 122ms
memory: 37852kb
input:
20
output:
9
result:
ok single line: '9'
Test #3:
score: 0
Accepted
time: 132ms
memory: 38520kb
input:
50
output:
17
result:
ok single line: '17'
Test #4:
score: 0
Accepted
time: 126ms
memory: 38520kb
input:
6
output:
4
result:
ok single line: '4'
Test #5:
score: 0
Accepted
time: 122ms
memory: 38804kb
input:
87
output:
26
result:
ok single line: '26'
Test #6:
score: 0
Accepted
time: 130ms
memory: 37384kb
input:
609
output:
130
result:
ok single line: '130'
Test #7:
score: 0
Accepted
time: 135ms
memory: 38000kb
input:
5126
output:
806
result:
ok single line: '806'
Test #8:
score: 0
Accepted
time: 159ms
memory: 37128kb
input:
92180
output:
10905
result:
ok single line: '10905'
Test #9:
score: 0
Accepted
time: 132ms
memory: 38788kb
input:
984096
output:
95960
result:
ok single line: '95960'
Test #10:
score: 0
Accepted
time: 131ms
memory: 37828kb
input:
5744387
output:
494209
result:
ok single line: '494209'
Test #11:
score: 0
Accepted
time: 124ms
memory: 37428kb
input:
51133311
output:
3851066
result:
ok single line: '3851066'
Test #12:
score: 0
Accepted
time: 167ms
memory: 38964kb
input:
607519174
output:
40319008
result:
ok single line: '40319008'
Test #13:
score: 0
Accepted
time: 168ms
memory: 38636kb
input:
7739876803
output:
456270136
result:
ok single line: '456270136'
Test #14:
score: 0
Accepted
time: 294ms
memory: 37508kb
input:
80754680817
output:
4304423738
result:
ok single line: '4304423738'
Test #15:
score: 0
Accepted
time: 1306ms
memory: 37480kb
input:
1000000000000
output:
48366248808
result:
ok single line: '48366248808'
Test #16:
score: 0
Accepted
time: 648ms
memory: 39064kb
input:
300000000000
output:
15176932897
result:
ok single line: '15176932897'
Test #17:
score: 0
Accepted
time: 819ms
memory: 38060kb
input:
500000000000
output:
24808936807
result:
ok single line: '24808936807'
Test #18:
score: 0
Accepted
time: 1004ms
memory: 38656kb
input:
700000000000
output:
34300642547
result:
ok single line: '34300642547'
Test #19:
score: 0
Accepted
time: 1084ms
memory: 38124kb
input:
790673894439
output:
38570752521
result:
ok single line: '38570752521'