QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#621555 | #4634. Factor | Crysfly | WA | 510ms | 28488kb | C++14 | 1.3kb | 2024-10-08 15:21:37 | 2024-10-08 15:21:41 |
Judging History
answer
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define int long long
using namespace std;
typedef vector<int>vi;
#define pb push_back
#define maxn 4000005
int pri[maxn],tot;
bool vis[maxn];
int sum[maxn];
void sieve(int n){
vis[1]=1;
For(i,2,n){
if(!vis[i]){
pri[++tot]=i;
}
For(j,1,tot){
int x=i*pri[j];
if(x>n)break;
vis[x]=1;
if(i%pri[j]==0)break;
}
}
For(i,1,n) sum[i]=sum[i-1]+(!vis[i]);
}
int n,B;
int res;
void dfs(int u,int xs,int id){
if(u>n) return;
++res;
// cout<<"add "<<u<<"\n";
for(int i=id; i<=tot; ++i){
if(u*pri[i]>n) break;
if(pri[i]>xs+1) break;
if(u*pri[i]*pri[i]>n){
int r=min(xs+1,n/u);
res+=sum[r]-sum[pri[i]-1];
return;
}
int p=pri[i];
int v=u,sv=1,pw=1;
for(int j=1; ;++j){
pw*=p;
sv+=pw;
v*=p;
if(v>n)break;
dfs(v,xs*sv,i+1);
}
}
}
signed main()
{
cin>>n;
B=sqrt(n)+1;
sieve(2000005);
dfs(1,1,1);
cout<<res;
return 0;
}
/*
1000000000000
50
1 2 4 6 8 12 16 18 20 24 28 30 32 36 40 42 48
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 10ms
memory: 24920kb
input:
10
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 10ms
memory: 27228kb
input:
20
output:
9
result:
ok single line: '9'
Test #3:
score: 0
Accepted
time: 7ms
memory: 27888kb
input:
50
output:
17
result:
ok single line: '17'
Test #4:
score: 0
Accepted
time: 10ms
memory: 25268kb
input:
6
output:
4
result:
ok single line: '4'
Test #5:
score: 0
Accepted
time: 10ms
memory: 24960kb
input:
87
output:
26
result:
ok single line: '26'
Test #6:
score: 0
Accepted
time: 14ms
memory: 25644kb
input:
609
output:
130
result:
ok single line: '130'
Test #7:
score: 0
Accepted
time: 10ms
memory: 25588kb
input:
5126
output:
806
result:
ok single line: '806'
Test #8:
score: 0
Accepted
time: 5ms
memory: 28488kb
input:
92180
output:
10905
result:
ok single line: '10905'
Test #9:
score: 0
Accepted
time: 7ms
memory: 27632kb
input:
984096
output:
95960
result:
ok single line: '95960'
Test #10:
score: 0
Accepted
time: 9ms
memory: 25432kb
input:
5744387
output:
494209
result:
ok single line: '494209'
Test #11:
score: 0
Accepted
time: 7ms
memory: 28252kb
input:
51133311
output:
3851066
result:
ok single line: '3851066'
Test #12:
score: 0
Accepted
time: 17ms
memory: 27588kb
input:
607519174
output:
40319008
result:
ok single line: '40319008'
Test #13:
score: 0
Accepted
time: 18ms
memory: 26372kb
input:
7739876803
output:
456270136
result:
ok single line: '456270136'
Test #14:
score: 0
Accepted
time: 92ms
memory: 28284kb
input:
80754680817
output:
4304423738
result:
ok single line: '4304423738'
Test #15:
score: -100
Wrong Answer
time: 510ms
memory: 24580kb
input:
1000000000000
output:
48365646601
result:
wrong answer 1st lines differ - expected: '48366248808', found: '48365646601'