SevenAlarm's blog

By SevenAlarm, history, 37 hours ago, In English

Hello to Codeforces community! I pretty much am taking this as a clickbait but Codeforces system thing just sent me a message saying that I'm apparently winning a prize from the NEAR contest. They sent me this link to connect my cf account with NEAR but when I click on the link it gives an error code 500 — Internal Server Error. I'm not quite familiar with servers and stuff so I just wanted to make sure, if you are getting a prize as well, is it like this for everyone now?

I'd be thankful if you tell me, I'm too Excited for my own good (Idek how much an NEAR is lol)

Full text and comments »

  • Vote: I like it
  • +6
  • Vote: I do not like it

By SevenAlarm, history, 4 days ago, In English

Hello cf community. I've recently grown quite eager of my rating change and honestly cant wait until the ratings update. I had heard of these Telegram Bots/Chrome extensions which make predictions of your rating change after a contest (probably based on your net ranking?) and searched them up, but non of them worked for me. Does any one know/use one? I'd be thankful if you suggest.

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it

By SevenAlarm, history, 7 months ago, In English

Hi! This is my first ever post on Codeforces XD I've solved 484A - Bits this problem and it works fine with the tastcases given in the submission details in my own compiler (I'm using vscode) but is apparently giving different outputs on Codeforces' judge. And the difference is like, off by 1!

I've attached the screenshots from 1)cf output & 2)my original output also here's my code:

#include <bits/stdc++.h>

using namespace std;
long long l, r;
long long p, ans = 0; // ans = 32

int main()
{
    int n, lg1, lg2;


    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> l >> r; // 38 , 63
        lg1 = log2(l); // 5
        lg2 = log2(r); // 5

        if (lg1 != lg2)
        {
            if (r == pow(2, lg2 + 1) - 1)
            {
                ans = pow(2, lg2 + 1) - 1;
            }
            else
            {
                ans = pow(2, lg2) - 1;
            }
        }
        else
        {
            if (r == l)
            {
                ans = l;
            }
            else
            {
                int i = lg1; // i = 5 ,
                ans = 0;
                while (lg1 == lg2)
                {
                    p = pow(2, i); // 32
                    if (l >= p)
                        ans += p;
                    l %= p;        // 6
                    r %= p;        // 31
                    lg1 = log2(l); // 2
                    lg2 = log2(r); // 4
                    i--;
                }

                if (r == pow(2, lg2 + 1) - 1)
                {
                    ans += r;
                }
                else
                {
                    ans += pow(2, lg2) - 1;
                }
            }
        }

        cout << ans << endl;
    }
}

I'm assuming there's some problem with the values being very large, since the bug happens with the 18 digit testcase lol. Could there be some memory trick that I can do? I'm relatively new to the c++ community and would be very happy to get ur tips.

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it