QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#708319#9248. An Easy Math ProblemThisTimeAC ✓134ms3976kbC++232.1kb2024-11-03 21:24:162024-11-03 21:24:17

Judging History

你现在查看的是最新测评结果

  • [2024-11-03 21:24:17]
  • 评测
  • 测评结果:AC
  • 用时:134ms
  • 内存:3976kb
  • [2024-11-03 21:24:16]
  • 提交

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];
         }
     }
     int cnt = (int)v.size();
     int ans = 0;
     int ans1 = 0;
     // for(auto x : v) {
     //     cout << x << ' ' << s[x] << endl;
     // }
     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 == 1) {
            ans1 += sum1;
         }
         else if(res >= 2) {
            ans += sum1 * ((int)pow(2ll,res) - 2ll); 
            ans1 += sum1;
         }

      }
      cout << ans / 2 + ans1 + 1<< endl;
} 
signed main()
{  
   
   cin.tie(nullptr); 
   ios::sync_with_stdio(false); 
   int kk = 1;
   cin >> kk;
   // cin.get();
   while(kk--) solve();
   return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3792kb

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: 0
Accepted
time: 40ms
memory: 3976kb

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
23
95
68
14
8
68
203
14
23
32
38
41
8
8
14
2
608
41
158
338
23
41
14
5
14
41
14
203
41
14
17
446
5
53
59
878
2
14
365
203
14
203
2
122
32
95
41
41
5
23
14
41
5
5
14
122
23
203
608
23
41
122
2
14
95
2
68
41
203
14
230
41
68
23
50
14
32
14
8
5
5
5
68
68
122
293
473
5
41
41
14
2
14
14
5
2
122
...

result:

ok 2000 lines

Extra Test:

score: 0
Extra Test Passed