CSES - Aalto Competitive Programming 2024 - wk12 - Wed - Results
Submission details
Task:Rabbits
Sender:arnxxau
Submission time:2024-11-27 17:49:36 +0200
Language:C++ (C++20)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#20.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#60.00 sdetails
#70.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.01 sdetails
#10ACCEPTED0.00 sdetails
#110.00 sdetails
#12ACCEPTED0.00 sdetails
#130.00 sdetails
#14ACCEPTED0.00 sdetails
#150.00 sdetails
#16ACCEPTED0.00 sdetails
#17ACCEPTED0.00 sdetails
#18ACCEPTED0.00 sdetails
#190.00 sdetails
#200.00 sdetails
#21ACCEPTED0.00 sdetails
#22ACCEPTED0.00 sdetails
#23ACCEPTED0.00 sdetails

Code

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int compare(const string& x, const string& y) {
    if (x.size() != y.size()) {
        return x.size() < y.size() ? -1 : 1;
    }
    for (size_t i = 0; i < x.size(); ++i) {
        if (x[i] != y[i]) {
            return x[i] < y[i] ? -1 : 1;
        }
    }
    return 0;
}

string add(const string& x, const string& y) {
    string result;
    int carry = 0, sum = 0;
    int i = x.size() - 1, j = y.size() - 1;
    while (i >= 0 || j >= 0 || carry) {
        sum = carry;
        if (i >= 0) {
            sum += x[i];
            i--;
        }
        if (j >= 0) {
            sum += y[j];
            j--;
        }
        carry = sum / 10;
        result.push_back((sum % 10) + '0');
    }
    reverse(result.begin(), result.end());
    return result;
}

int main() {
    string a, b;
    cin >> a >> b;

    string fib1 = "1", fib2 = "1", fib3;
    int count = 0;

    if (compare("1", a) >= 0 && compare("1", b) <= 0) {
        count++;
    }

    while (true) {
        fib3 = add(fib1, fib2);
        fib1 = fib2;
        fib2 = fib3;

        if (compare(fib3, a) >= 0 && compare(fib3, b) <= 0) {
            count++;
        } else if (compare(fib3, b) > 0) {
            break;
        }
    }

    cout << count << endl;
}

Test details

Test 1

Verdict:

input
1 1000000000000000000000000000...

correct output
480

user output
100

Test 2

Verdict:

input
1 1

correct output
2

user output
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:

input
636957196297222930779072940972...

correct output
0

user output
1

Test 7

Verdict:

input
114612974378925787282507968062...

correct output
3

user output
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:

input
639748223313530085297872188565...

correct output
0

user output
1

Test 12

Verdict: ACCEPTED

input
432993801671766821076571962007...

correct output
1

user output
1

Test 13

Verdict:

input
879671727283213079665539196480...

correct output
1

user output
0

Test 14

Verdict: ACCEPTED

input
667785392416865594397610159182...

correct output
0

user output
0

Test 15

Verdict:

input
781364162388340525444583784264...

correct output
1

user output
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: ACCEPTED

input
447646307232291168178477866864...

correct output
1

user output
1

Test 19

Verdict:

input
295276605018840332007572176705...

correct output
5

user output
1

Test 20

Verdict:

input
443559664146440701189824727251...

correct output
2

user output
1

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