QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#708292#9248. An Easy Math ProblemThisTimeWA 134ms3996kbC++232.0kb2024-11-03 21:11:332024-11-03 21:11:34

Judging History

This is the latest submission verdict.

  • [2024-11-03 21:11:34]
  • Judged
  • Verdict: WA
  • Time: 134ms
  • Memory: 3996kb
  • [2024-11-03 21:11:33]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
// #pragma GCC optimize (1)
// #pragma GCC optimize (2)
// #pragma GCC optimize (3)
#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 all(a) a.begin(),a.end()
#define db double
#define endl '\n'
#define ff first
#define ss second
#define lc p<<1
#define rc p<<1|1
using namespace std;
using i64 = long long;
const int N = 1e6+10;
const int M = 1e6+10;
const int mod1 = 998244353;
const int mod2 = 1e9+7;
const int INF = 0x3f3f3f3f3f3f3f;
const double eps = 1e-10;
void solve(){
     map<int,int>s;
     std::vector<int> v;
     int n;
     cin >> n;
     if(n == 1) {
         cout << 1 << endl;
         return;
     }
     int sum = 0;
     int ss = 1;
     for(int i = 2 ; i * i <= n ; i++) {
         if(n % i == 0) {
            v.push_back(i);
            while(n % i == 0) {
               n/=i;
               s[i]++;
            }
            sum++;
            ss *= s[i];
         }
     }
     if(n > 1) {
         if(s[n] == 0) {
            s[n] = 1;
            v.push_back(n);
            sum++;
            ss *= s[n];
         }
     }
     // v.push_back(1);
     // s[1] = 1;
     int cnt = (int)v.size();
     int ans = 0;
     for(int i = 0; i < (1ll << cnt); i++) {
         int res = 0;
         int sum1 = 1ll;
         for(int j = 0; j < cnt; j++) {
            if((i & (1ll<< (j))) != 0) {
               res++;
               sum1 *= s[v[j]];
            } 
         }
         if(res >= 2) {
            ans += sum1 * ((int)pow(2ll,res) - 2ll); 
         }
      }
      // deg(sum);
      // deg(ss);
      cout << ans / 2 + ss * ((int)pow(2,sum) - 1) + 1<< endl;
} 
signed main()
{  
   
   cin.tie(nullptr); 
   ios::sync_with_stdio(false); 
   int kk = 1;
   cin >> kk;
   // cin.get();
   while(kk--) solve();
   return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 134ms
memory: 3856kb

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: 37ms
memory: 3864kb

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:

14
5
2
5
26
109
75
14
9
75
264
14
26
38
49
41
9
9
14
2
639
41
201
391
26
41
14
5
14
41
14
218
41
14
21
506
5
72
74
1083
2
14
410
218
14
218
2
122
38
109
41
41
5
26
14
50
5
5
14
122
26
218
639
26
41
122
2
14
109
2
75
41
218
14
279
41
75
26
62
14
38
14
9
5
5
5
75
75
122
390
564
5
41
41
14
2
14
14
5
2
...

result:

wrong answer 5th lines differ - expected: '23', found: '26'