| Task: | Rabbits |
| Sender: | ariadna.roga |
| Submission time: | 2025-11-26 17:48:38 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.00 s | details |
| #2 | WRONG ANSWER | 0.00 s | details |
| #3 | ACCEPTED | 0.00 s | details |
| #4 | ACCEPTED | 0.00 s | details |
| #5 | ACCEPTED | 0.00 s | details |
| #6 | ACCEPTED | 0.00 s | details |
| #7 | WRONG ANSWER | 0.00 s | details |
| #8 | ACCEPTED | 0.00 s | details |
| #9 | ACCEPTED | 0.00 s | details |
| #10 | ACCEPTED | 0.00 s | details |
| #11 | ACCEPTED | 0.00 s | details |
| #12 | WRONG ANSWER | 0.00 s | details |
| #13 | WRONG ANSWER | 0.00 s | details |
| #14 | ACCEPTED | 0.00 s | details |
| #15 | WRONG ANSWER | 0.01 s | details |
| #16 | ACCEPTED | 0.00 s | details |
| #17 | ACCEPTED | 0.00 s | details |
| #18 | WRONG ANSWER | 0.00 s | details |
| #19 | WRONG ANSWER | 0.00 s | details |
| #20 | WRONG ANSWER | 0.00 s | details |
| #21 | ACCEPTED | 0.00 s | details |
| #22 | ACCEPTED | 0.00 s | details |
| #23 | ACCEPTED | 0.00 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
/*
Far far away in the future, humanity has sent 1 frozen newborn rabbit pair to populate an alien planet. Each pair of rabbits reaches maturity at the age of 1 month and they immediately mate. One month after mating the pair reproduces one pair of rabbits, after which the older pair mates again immediately. The rabbits never die and continue breeding forever.
How many months will the rabbit population be in an interval between a and b?
Input:
The first line contains 2 integers a,\,b: the interval boundaries.
Output:
Print a single integer d: the duration (in months) when the number of rabbit pairs is in the interval [a,\,b] inclusive.
Constraints:
1 \leq a \leq b \leq 10^{100}*/
long long fibonacci (long long i) {
if (i == 0)
return 0;
if (i == 1)
return 1;
return fibonacci (i - 1) + fibonacci (i - 2);
}
int main()
{
// ios_base::sync_with_stdio(0);
// cin.tie(0);
int a, b;
cin >> a >> b;
if (a <=2 )
cout << 1;
else {
long long fib1 = 1;
long long fib2 = 2;
while (fib2 < a) {
long long temp = fib2;
fib2 = fib1 + fib2;
fib1 = temp;
}
if (fib2 > b) {
cout << 0 << endl;
}
else {
long long count = 0;
while (fib2 <= b) {
++count;
long long temp = fib2;
fib2 = fib1 + fib2;
fib1 = temp;
}
cout << count << endl;
}
}
}Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 1 1000000000000000000000000000... |
| correct output |
|---|
| 480 |
| user output |
|---|
| 1 |
Feedback: Incorrect character on line 1 col 1: expected "480", got "1"
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 1 1 |
| correct output |
|---|
| 2 |
| user output |
|---|
| 1 |
Feedback: Incorrect character on line 1 col 1: expected "2", got "1"
Test 3
Verdict: ACCEPTED
| input |
|---|
| 100000000000000000000000000000... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 708610693340620844512521044951... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 786632967217302919379405189471... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 636957196297222930779072940972... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| 114612974378925787282507968062... |
| correct output |
|---|
| 3 |
| user output |
|---|
| 0 |
Feedback: Incorrect character on line 1 col 1: expected "3", got "0"
Test 8
Verdict: ACCEPTED
| input |
|---|
| 702530369037899946705172780410... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 274453166590443997807512962944... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 10
Verdict: ACCEPTED
| input |
|---|
| 855307457139726034048493902602... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 11
Verdict: ACCEPTED
| input |
|---|
| 639748223313530085297872188565... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 12
Verdict: WRONG ANSWER
| input |
|---|
| 432993801671766821076571962007... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 0 |
Feedback: Incorrect character on line 1 col 1: expected "1", got "0"
Test 13
Verdict: WRONG ANSWER
| input |
|---|
| 879671727283213079665539196480... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 0 |
Feedback: Incorrect character on line 1 col 1: expected "1", got "0"
Test 14
Verdict: ACCEPTED
| input |
|---|
| 667785392416865594397610159182... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 15
Verdict: WRONG ANSWER
| input |
|---|
| 781364162388340525444583784264... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 0 |
Feedback: Incorrect character on line 1 col 1: expected "1", got "0"
Test 16
Verdict: ACCEPTED
| input |
|---|
| 655747298541157143247235560738... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 17
Verdict: ACCEPTED
| input |
|---|
| 403413620814634912261621439265... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 18
Verdict: WRONG ANSWER
| input |
|---|
| 447646307232291168178477866864... |
| correct output |
|---|
| 1 |
| user output |
|---|
| 0 |
Feedback: Incorrect character on line 1 col 1: expected "1", got "0"
Test 19
Verdict: WRONG ANSWER
| input |
|---|
| 295276605018840332007572176705... |
| correct output |
|---|
| 5 |
| user output |
|---|
| 0 |
Feedback: Incorrect character on line 1 col 1: expected "5", got "0"
Test 20
Verdict: WRONG ANSWER
| input |
|---|
| 443559664146440701189824727251... |
| correct output |
|---|
| 2 |
| user output |
|---|
| 0 |
Feedback: Incorrect character on line 1 col 1: expected "2", got "0"
Test 21
Verdict: ACCEPTED
| input |
|---|
| 734298173292503577661407215818... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 22
Verdict: ACCEPTED
| input |
|---|
| 864568133527920094870111453259... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 23
Verdict: ACCEPTED
| input |
|---|
| 352783378945989078522092015452... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
