QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#591478#7797. Based ZerosStrausKoldunTL 0ms0kbC++171.0kb2024-09-26 16:06:052024-09-26 16:06:06

Judging History

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

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

answer

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

void solve() {
  int n;
  cin >> n;
  map<int, int> mem;
  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: