QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#701170 | #9248. An Easy Math Problem | 53Dawns# | WA | 496ms | 8808kb | C++23 | 1.5kb | 2024-11-02 13:51:30 | 2024-11-02 13:51:33 |
Judging History
answer
#include<bits/stdc++.h>
#define deg(a) cout << #a << '=' << a << "\n"
#define all(a) a.begin(),a.end()
#define lowbit(x) ((x)&(-x))
#define find1(x) (__builtin_popcount(x))
#define pll pair<int,int>
#define int long long
#define endl '\n'
#define ff first
#define ss second
#define ULL unsigned long long
#define lc p << 1
#define rc p << 1|1
using namespace std;
using i64 = long long;
const int N = 1e5+10;
const int M = 1e6+10;
const int mod2 = 998244353;
const int mod1 = 1e9+7;
const int inf = 0x3f3f3f3f3f3f3f;
const double eps = 1e-12;
const int bit1 = 13331;// 底数1
const int bit2 = 13;// 底数
int f[N];
unordered_set<int>st;
void init(){
for(int i=1;i<N;++i){
for(int j=i;j<N;j+=i){
f[j]++;
}
}
for(int i=1;i<N;++i){
f[i]=(f[i]+1)/2;
}
for(int i=2;i<N;++i){
int x=i*i;
st.insert(x);
for(int j=x;j<N;j+=x){
f[j]--;
}
}
}
void solve(){
int n;
cin>>n;
vector<int>d;
for(int i=1;i*i<=n;++i){
if(n%i==0){
d.push_back(i);
if(n/i!=i) d.push_back(n/i);
}
}
int ans=0,cnt=0;
for(auto v:d){
if(v < N) ans += f[v];
if(st.count(v)) cnt++;
}
if(n>=N){
ans+=(d.size()+1)/2-cnt;
}
cout<<ans<<'\n';
}
signed main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int kk = 1;
cin >> kk;
init();
// cin.get();
while(kk--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 11ms
memory: 8696kb
input:
10 1 2 3 4 5 6 7 8 9 10
output:
1 2 2 3 2 5 2 4 3 5
result:
ok 10 lines
Test #2:
score: -100
Wrong Answer
time: 496ms
memory: 8808kb
input:
2000 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 6469693230 646969323...
output:
5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 5437 ...
result:
wrong answer 1st lines differ - expected: '29525', found: '5437'