QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#616732#9248. An Easy Math Problemucup-team4153#WA 66ms4220kbC++201.1kb2024-10-06 10:49:282024-10-06 10:49:29

Judging History

This is the latest submission verdict.

  • [2024-10-31 22:36:43]
  • hack成功,自动添加数据
  • (/hack/1098)
  • [2024-10-31 22:13:58]
  • hack成功,自动添加数据
  • (/hack/1096)
  • [2024-10-31 22:00:43]
  • hack成功,自动添加数据
  • (/hack/1095)
  • [2024-10-06 10:49:29]
  • Judged
  • Verdict: WA
  • Time: 66ms
  • Memory: 4220kb
  • [2024-10-06 10:49:28]
  • Submitted

answer

#include<bits/stdc++.h>

using namespace std;
const int N = 1e5 + 7;
typedef long long ll;
int tot;
int vis[N], prime[N];

void seive() {
    for (int i = 2; i < N; i++) {
        if (!vis[i])prime[++tot] = i;
        for (int j = 1; j <= tot && i * prime[j] < N; j++) {
            vis[i * prime[j]] = 1;
        }
    }
}

ll ans;

void dfs(int st, int cnt, vector<int> &p) {
//    cout<<cnt<<"\n";
    if (st == p.size()) {
        cnt=max(cnt-1,0);
        ans+=1<<cnt;
        return;
    }
    for(int i=0;i<=p[st];i++)dfs(st+1,cnt+(i!=0),p);
}

void solve() {
    ll n;cin>>n;
    vector<int> factor;
    for (int i = 1; i <= tot; i++) {
        if (n % prime[i] == 0) {
            int cnt = 0;
            while (n % prime[i] == 0) {
                cnt++;
                n /= prime[i];
            }
            factor.push_back(cnt);
        }
    }
    ans = 0;
    dfs(0, 0, factor);
    cout << ans << "\n";
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    seive();
    int T;
    cin >> T;
    while (T--)solve();
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 4164kb

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: 0
Accepted
time: 66ms
memory: 3988kb

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:

29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
29525
...

result:

ok 2000 lines

Test #3:

score: -100
Wrong Answer
time: 57ms
memory: 4220kb

input:

2000
1763047095
79735483
1016286871
2864801397
2327774116
2668010360
3469893354
3634459021
1613699068
781737219
574741575
2763134701
1458502604
1822260248
2281150332
2924219311
2493931196
3735904708
158802001
2006921221
729928782
1974841034
727412600
2873393292
1291087179
2741607663
1893408215
29827...

output:

5
5
1
2
8
95
23
14
3
68
203
5
8
11
13
41
3
3
14
1
608
41
158
113
8
41
5
2
5
41
5
203
41
5
6
446
2
18
20
878
1
5
365
203
5
68
1
122
32
32
41
14
2
23
5
14
2
2
5
122
8
203
608
8
41
122
1
5
32
1
68
41
68
5
230
14
23
8
17
5
11
14
3
2
2
2
23
68
41
293
473
2
14
41
14
1
5
5
2
1
122
41
11
23
5
1
14
2
14
14
8...

result:

wrong answer 1st lines differ - expected: '14', found: '5'