結果

問題 No.2 素因数ゲーム
ユーザー yuuki arisawayuuki arisawa
提出日時 2021-03-23 03:03:59
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 8,483 bytes
コンパイル時間 2,310 ms
コンパイル使用メモリ 211,908 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-16 06:35:41
合計ジャッジ時間 7,003 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
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 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// set<int, greater<int> > s;
// vector<int> v(N);
// for(int i =0;i<N;i++){
//   cin >> v.at(i);
// }
// single line with multi param
// vector of vector
//   vector<vector<int>> data(row,vector<int>(col));
// for(int row=0;row<N;row++){
//    for(int col=0;col<N;col++){
//      cin >> data[row][col];
//  }}
//  cout << std::fixed << std::setprecision(9) <<ret << endl;
// sort(A.begin(),A.end(),greater<int>());
// long long s = accumulate(A.begin(),A.end(),(long long)0);
// unordered_map<string,int>m({{"SUN",1},{"MON",2},{"TUE",3},{"WED",4},{"THU",5},{"FRI",6},{"SAT",7}});
// max({A,B,C});
// S.substr(i,2)=="RS"
// SS.erase (std::remove(SS.begin(), SS.end(), 'A'), SS.end()); //delete string
// char c = 'a';string({c});
// transform(ret.begin(),ret.end(),ret.begin(),::toupper);
// to be review
// * abc139_b
// * abc099_b
// * abc090_a
// * abc062_a
// * abc032_a
// * abc030_b
// * abc027_b
// * abc021_a
// * abc018_a
// * abc182_c
// * abc181_c
// * abc175_c
// * abc170_c
// * abc161_c
// * abc154_c space O(1)
// * abc151_c
// * abc147_c
// * abc113_c
// * abc123_c
// * abc115_c
// * abc153_d
// * abc120_c
// * abc081_b
// * arc108_b
// * abc157_c
// * sumitrust2019_c
// * abc165_c
// * abc031_d
// * abc023_d
// * agc021_a
// * abc139_b
// * agc041_a
// * abc120_c
// * arc073_c
// * arc069_c
// * agc014_a
// * abc103_c
// * agc017_a
// * agc040_a
// * agc028_a
// * agc008_a
// * agc007_a
// * abc116_c
// * abc064_c
// * agc016_a
// * agc034_a
// * cf16_b
// * abc188_e
// * abc052_c
// * abc110_d
// * abc142_d
// * arc067_c
// * abc146_c
// * abc061_c
// * abc114_d
// * abc114_c
// * arc032_a
// * arc034_c
// * aoj_2706
// * aoj_DSL_3_D
// * abc172_c
// * arc084_c
// * arc110_a
// * apc001_a
// * abc124_d
// * arc106_b
// * abc157_d
// * agc046_a
// * abc185_d
// * arc044_a
// * abc046_a
// * abc039_c
// * arc107_b
// * arc054_a
// * abc136_d
// * arc051_a
// * abc180_d
// * abc190_d
// * abc121_d
// * abc038_c
// * abc130_d
// * abc127_d
// * arc018_b
// * arc001_c
// * digitalarts2012_a
// * code-festival-2015-quala_c
// * abc192_d
// * srm_StockHistory
// * dp_i
// * srm_BinaryFlips
// * abc088_c
// * past202004-open_d
// * past201912-open_e
// * past201912-open_h
// * past202005-open_g
// * abc161_d
// * dp_a
// * dp_e
// * past202005-open_h
// * tdpc_a
// * past202004-open_h
// * past201912-open_g
// * past202005-open_c
// * abc179_c
// * arc107_a
// * abc098_c
// * abc194_c
// * abc194_e
// * abc146_c
// * past202004_g
// * typical_algorithm_b
// * past201912_k
// * past202005_i
// * abc195_d
// * past202005_m
// * past201912_j
// * abc099_c
// * abc196_d
// * arc115_a
// * arc115_c
// check list
// * variable range
// * immeditate value is int range(accumulate)
// * index range(0 origin or 1 origin)
// * input is complete?
// * unued input
// * loop initial value
// * check variable range maximum and minimum
// * misunderstand input(node Edge and node Vertex)
// * check que front and back
// * check not using INT_MAX but LONG_LONG_MAX
// * modify element in graph retrieval
// * dp initial value, max index+1
// * return value could be negative?(initial value 0 to INT_MIN)
// * if value is gradually increasing, use bin search
// * Time complexity limit 10^8
#include <bits/stdc++.h>
using namespace std;

// https://www2.slideshare.net/Roadagain/ss-71620380
// https://github.com/kurokoji/.cpp-Template/blob/master/template/template.cpp
#define int long long
// check over flow
// assert(a<LONG_LONG_MAX-b)
// a+b
// assert(a<LONG_LONG_MAX/b)
// a*b
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
    }
} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define RALL(v) rbegin(v), rend(v)
// #define X real()
// #define Y imag()

/* debug */
#define debug(x)                  \
    cerr << #x << ":" << x << " " \
         << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
// const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; }
template <class T = int>
inline T in() {
    T x;
    cin >> x;
    return (x);
}
inline vs split(const string& t, char c) {
    vs v;
    stringstream s(t);
    string b;
    while (getline(s, b, c))
        if (b != "") v.eb(b);
    return v;
}
inline string join(const vs& ss, char c) {
    string s;
    for (int i = 0; i < (int)ss.size(); i++) {
        s += (i != (ll)ss.size() - 1 ? ss[i] + c : ss[i]);
    }
    return s;
}
template <typename T>
inline bool chmin(T& a, const T& b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b) a = b;
    return a < b;
}

template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

template <typename T, typename S>
inline void print(const pair<T, S>& p) {
    cout << p.first << " " << p.second << endl;
}
template <typename T>
inline void print(const T& x) {
    cout << x << '\n';
}
template <typename T, typename S>
inline void print(const vector<pair<T, S>>& v) {
    for (auto&& p : v) print(p);
}
template <typename T>
inline void print(const vector<T>& v, string s = " ") {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i != (long long)v.size() - 1 ? s : "\n");
}
template <typename T>
inline void print(const T& b, const T& e, string s = " ") {
    for (auto i = b; i != e; i++) print(*i);
}
template <typename T>
void pprint(T const& a) {
    std::cout << " " << a;
}
template <typename... Args>
void pp(Args... args) {
    using swallow = std::initializer_list<int>;
    (void)swallow{(void(pprint(args)), 0)...};
    cout << endl;
}

template <typename T>
inline vector<pair<T, int>> counter(const vector<T>& v) {
    unordered_map<T, int> m;
    for (int i = 0; i < v.size(); i++) m[v[i]]++;
    return {m.begin(), m.end()};
}
inline vector<pair<char, int>> counter(const string& v) {
    unordered_map<char, int> m;
    for (int i = 0; i < (long long)v.size(); i++) m[v[i]]++;
    return {m.begin(), m.end()};
}
// clang-format on
/* }}} */

string enc(long long i, long long j) { return to_string(i) + " " + to_string(j); }
uint64_t combinations2(uint64_t n, uint64_t k) {
    uint64_t r = 1;
    for (uint64_t d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

#define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))
#define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))
#define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

vector<pair<long long, long long> > prime_factorize(long long N) {
  vector<pair<long long, long long> > res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    long long ex = 0; // 指数

    // 割れる限り割り続ける
    while (N % a == 0) {
      ++ex;
      N /= a;
    }

    // その結果を push
    res.push_back({a, ex});
  }

  // 最後に残った数について
  if (N != 1) res.push_back({N, 1});
  return res;
}

const string FIRST = "Alice";
const string SECOND = "Bob";
bool solve(int64_t N) {
  if(N<=1)
    return false;
  for(const auto [p,f]:prime_factorize(N)){
    int d = p;
    REP(i,f){
      pp(N,i,d);
      if(solve(N/d)==false)
        return true;
      d*=p;
    }
  }
  return false;
}

// generated by oj-template v4.7.2 (https://github.com/online-judge-tools/template-generator)
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int64_t N;
    cin >> N;
    auto ans = solve(N);
    cout << (ans ? FIRST : SECOND) << endl;
    return 0;
}
0