Biến Đổi Cặp Số

Đề bài

Mô tả

Bessie likes cooking and wants to prepare a meal. She has a number of recipes and wants to pick one to use. However, she has a difficult time deciding between recipes, and she will cook the meal from the recipe that is chosen by a fair game.

This game involves a list of n pairs of integers. Each pair of integers (ai,bi) has some information written on it. In each step of the game, Bessie picks a pair and performs one of two operations on it:

  • Operation A: (a,b)(b,a+b)
  • Operation B: (a,b)(a+b,b)

The game continues until all pairs are of the form (Fk,Fk+1) for some integer k1, where Fi is the i-th Fibonacci number.

How many pairs can Bessie modify?

Dữ liệu vào

Dòng đầu tiên chứa n (1n105), số lượng cặp.

n dòng tiếp theo, mỗi dòng chứa hai số nguyên aibi (1ai,bi109).

Dữ liệu ra

In ra số lượng cặp mà Bessie có thể biến đổi thành dạng (Fk,Fk+1).

Ràng buộc

1n105 1ai,bi109

Ví dụ

Input Output Giải thích
2
1 1
3 5
2 Cả hai cặp đều là Fibonacci
3
1 2
5 8
2 2
2 Chỉ hai cặp (1,2) và (5,8) là Fibonacci

Bình luận

Không có bình luận tại thời điểm này.

gnatmake 12.2.0 a68g 3.1.2 nasm 2.16.1 as_x64 2.46 awk 1.3.4 gcc 16.1.0 csc 6.12.0.200 g++ 16.1.0 g++-themis 16.1.0 g++17 16.1.0 g++20 16.1.0 g++23 16.1.0 clang++ 22.1.6 dmd 2.112.0 dart 3.12.1 gforth 0.7.3 gfortran 12.2.0 go 1.26.3 groovyc 5.0.6 javac 25.0.3 node 26.2.0 kotlinc 2.3.21 sbcl 2.2.9 lua 5.4.8 nim 2.2.10 fpc 3.2.2 fpc-themis 3.2.2 perl 5.36.0 php 8.5.6 pike 8.0 pypy3 7.3.23 python3 3.14.5 racket 8.7 ruby 4.0.5 rustc 1.96.0 csc 5.3.0 ctoj-scratch 0.0.1 sed 4.9 tclsh 8.6 bun 1.3.14 deno 2.8.1 v 0.5.1 zig 0.16.0