結果

問題 No.1871 divisXor
ユーザー Shun_PIShun_PI
提出日時 2022-03-11 22:27:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,772 bytes
コンパイル時間 2,761 ms
コンパイル使用メモリ 192,444 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-14 07:41:44
合計ジャッジ時間 9,441 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,352 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,348 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 15 ms
4,348 KB
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N;
  cin >> N;
  if(N == 0) {
    cout << -1 << endl;
  } else {
    vector<lint> res;
    for(lint i=1; i*i<=N; i++) {
      if (N%i == 0) {
        res.push_back(i);
        if (N/i != i) res.push_back(N/i);
      }
    }
    sort(ALL(res));
    vector<lint> ans;
    ans.push_back(N);
    vector<bool> valid(res.size(), true);
    valid[res.size()-1] = false;
    IREP(i, res.size()-1) if(valid[i]) {
      ans.push_back(res[i]);
      set<lint> res2;
      N = res[i];
      for(lint i=1; i*i<=N; i++) {
        if (N%i == 0) {
          res2.insert(i);
          if (N/i != i) res2.insert(N/i);
        }
      }
      REP(j, res.size()) if(res2.find(res[j]) != res2.end()) valid[j] = !valid[j];
    }
    cout << ans.size() << endl;
    REP(i, ans.size()) cout << ans[i] << (i!=ans.size()-1 ? " " : "");
    cout << "\n";
  }
}
0