結果
| 問題 | 
                            No.1203 お菓子ゲーム
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Chanyuh
                         | 
                    
| 提出日時 | 2020-08-29 11:05:21 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 608 ms / 2,000 ms | 
| コード長 | 844 bytes | 
| コンパイル時間 | 391 ms | 
| コンパイル使用メモリ | 82,384 KB | 
| 実行使用メモリ | 78,076 KB | 
| 最終ジャッジ日時 | 2024-11-14 05:27:31 | 
| 合計ジャッジ時間 | 19,426 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 51 | 
ソースコード
def divisor_list(x):
  res=[]
  i=1
  while i*i<=x:
    if x%i==0:
      res.append(i)
      if i*i!=x:
        res.append(x//i)
    i+=1
  return res
        
n=int(input())
for i in range(n):
  ans=0
  x,y=map(int,input().split())
  #print(x,y)
  Dy=divisor_list(y)
  for d in Dy:
    if d%2==0:
      continue
    b=(d+1)//2
    if 2*b*(b-1)*y%((2*b-1)*x)!=0:
      continue
    A=2*b*(b-1)*y//((2*b-1)*x)
    #print(A,2*b-1)
    if A<=0 or A>100000000:  continue
    if A<=2*b-1: continue
    ans+=1
  for d in Dy:
    if d%2==0:
      continue
    a=(d+1)//2
    if 2*a*(a-1)*y%((2*a-1)*(y-x))!=0:
      continue
    B=2*a*(a-1)*y//((2*a-1)*(y-x))
    #print(2*a-1,B)
    if B<=0 or B>100000000: continue
    if B<=2*a-1: continue
    ans+=1
  if y>2*x:
    ans+=100000000//y
  if y>2*(y-x):
    ans+=100000000//y
  print(ans)
    
    
  
            
            
            
        
            
Chanyuh