QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#591488#7797. Based ZerosStrausKoldunTL 0ms0kbC++17955b2024-09-26 16:08:072024-09-26 16:08:07

Judging History

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

  • [2024-09-26 16:08:07]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-09-26 16:08:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

void solve() {
  int n;
  cin >> n;
  auto foo = [](int n, int base)
  {
    int res = 0;
    while (n != 0)
    {
      res += (n % base) == 0;
      n /= base;
    }
    return res;
  };
  pair<int, vector<int>> ans = {0, {}};
  vector<int> t;
  for (int i = 2; i <= 1e6; i++)
  {
    bool skip = false;
    for (auto j : t)
    {
      skip |= (j * j == i);
    }
    if(skip)
      continue;
    
    t.push_back(i);
    auto del = foo(n, i);
    if(ans.first == del){
      ans.second.push_back(i);
      continue;
    }
    if(ans.first < del){
      ans = {del, {i}};
      continue;
    }
  }
  cout << ans.first << " " << ans.second.size() << '\n';
  for (auto i : ans.second){
    cout << i << ' ';
  }
  cout << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

3
11
1007
239

output:


result: