結果

問題 No.1850 Rewrite Product
ユーザー umezoumezo
提出日時 2022-02-25 23:49:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 711 bytes
コンパイル時間 2,095 ms
コンパイル使用メモリ 206,224 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 19:26:17
合計ジャッジ時間 2,701 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

unordered_map<ll,bool> m;
bool f(ll x,ll y){
  if(x==y) return true;
  if(m.count(x)) return m[x];
  bool b=false;
  for(ll i=x+1;i<=sqrt(x);i++){
    if(i*(x-i)>y) continue;
    if(f(i*(x-i),y)){
      b=true;
      break;
    }
  }
  if(b) return true;
  else return false;
}

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int t;
  cin>>t;
  while(t--){
    ll x,y;
    cin>>x>>y;
    
    if(x>=y){
      cout<<"Yes"<<endl;
      continue;
    }
    
    if(f(x,y)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
   
  return 0;
}
0