luyencode / comments

Server lưu trữ bình luận trên Luyện Code
https://luyencode.net
6 stars 3 forks source link

https://oj.luyencode.net/problem/CD2B10 #764

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Đếm số Fibonacci - Luyện Code Online

https://luyencode.net/problem/CD2B10

phanhuykhang commented 2 years ago

test ví dụ sai rồi ad ơi, output phải là 7

Conan286 commented 2 years ago

ai chưa làm được tham khảo của mình tại: https://github.com/huycn9/c-cpp-basic/blob/main/count%20Fibonacci.cpp

luuquyhop commented 1 year ago

Đây là lời giải của mình đã AC. Nếu bạn đã cố gắng mà chưa làm được thì có thể tham khảo lời giải của mình.

Xem code AC

```java import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double m = sc.nextDouble(); double n = sc.nextDouble(); double a = 1.0, b = 1.0; int dem = 0; if (m == 1) dem = 2; else if (m == 2) dem = 1; while (b <= n) { b += a; a = b - a; if (b >= m) dem++; } System.out.println(dem - 1); } } ```