結果
問題 |
No.1895 Mod 2
|
ユーザー |
👑 ![]() |
提出日時 | 2022-04-08 22:01:10 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 909 bytes |
コンパイル時間 | 277 ms |
コンパイル使用メモリ | 82,140 KB |
実行使用メモリ | 156,212 KB |
最終ジャッジ日時 | 2024-11-28 12:41:26 |
合計ジャッジ時間 | 24,052 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 TLE * 7 |
ソースコード
def General_Binary_Decrease_Search_Integer(L,R,cond,default=None): """条件式が単調減少であるとき, 整数上で二部探索を行う. L:解の下限 R:解の上限 cond:条件(1変数関数,広義単調減少 or 広義単調減少を満たす) default: Rで条件を満たさないときの返り値 """ if not(cond(L)): return default if cond(R): return R L-=1 while R-L>1: C=L+(R-L)//2 if cond(C): L=C else: R=C return L #================================================== def g(x): y=1 a=0 while y<=x: check=lambda i:y*(2*i-1)**2<=x a+=General_Binary_Decrease_Search_Integer(1,x//y,check,0) y*=2 return a #================================================== T=int(input()) Ans=[0]*T for t in range(T): L,R=map(int,input().split()) Ans[t]=(g(R)-g(L-1))%2 print(*Ans,sep="\n")