結果

問題 No.1113 二つの整数 / Two Integers
ユーザー どららどらら
提出日時 2020-07-17 21:42:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,596 bytes
コンパイル時間 1,719 ms
コンパイル使用メモリ 178,100 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-20 00:19:39
合計ジャッジ時間 4,277 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,760 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘ull PollardRho(ull, ull)’ 内:
main.cpp:32:22: 警告: ‘y’ may be used uninitialized [-Wmaybe-uninitialized]
   32 |     p = gcd(n,llabs(x-y));
      |                     ~^~
main.cpp:24:9: 備考: ‘y’ はここで定義されています
   24 |   ull x,y,p;
      |         ^
関数 ‘ull PollardRho(ull, ull)’ 内,
    inlined from ‘std::vector<long long unsigned int> solvePollardRho(ull)’ at main.cpp:41:19:
main.cpp:32:22: 警告: ‘y’ may be used uninitialized [-Wmaybe-uninitialized]
   32 |     p = gcd(n,llabs(x-y));
      |                     ~^~
main.cpp: 関数 ‘std::vector<long long unsigned int> solvePollardRho(ull)’ 内:
main.cpp:24:9: 備考: ‘y’ はここで定義されています
   24 |   ull x,y,p;
      |         ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

typedef unsigned long long ull;
ull gcd(ull a, ull b){ return b==0?a:gcd(b,a%b); }
ull mulMod(ull a, ull b, ull mod){
  ull res = 0;
  a %= mod;
  while(b){
    if(b&1) res = (res+a)%mod;
    a = (a*2ULL)%mod;
    b = b/2ULL;
  }
  return res;
}
ull PollardRho(ull n, ull c=1){
  if(c>10) return -1ULL;
  ull x,y,p;
  x = p = 1ULL;
  int next=2, i=1;
  while(p==1){
    ++i;
    if(i==next){ y=x; next*= 2; }
    x = (mulMod(x,x,n)+c)%n;
    if(y==x) return PollardRho(n,c+1);
    p = gcd(n,llabs(x-y));
  }
  return p;
}
vector<ull> solvePollardRho(ull n){
  vector<ull> ret;
  ull r;
  while(true){
    if(n==1) break;
    r = PollardRho(n);
    if(r==-1ULL){ ret.push_back(n); sort(ret.begin(), ret.end()); return ret; }
    ret.push_back(r);
    n = n/r;
  }
  sort(ret.begin(), ret.end());
  return ret;
}


int main(){
  ull A, B;
  cin >> A >> B;

  vector<ull> x = solvePollardRho(A);
  vector<ull> y = solvePollardRho(B);

  map<ull,int> cntA, cntB, cnt;
  rep(i,x.size()){
    cntA[x[i]]++;
    cnt[x[i]] = 1;
  }
  rep(i,y.size()){
    cntB[y[i]]++;
    cnt[y[i]] = 1;
  }

  ull ans = 1;
  FOR(it,cnt){
    ull val = it->first;
    ull mn = min(cntA[val], cntB[val]);

    ans *= (mn+1);
  }

  if(ans % 2 == 0) cout << "Even" << endl;
  else cout << "Odd" << endl;
  
  return 0;
}
0