vedantsharma2508's blog

By vedantsharma2508, history, 4 months ago, In English

The problem statement here is https://codeforces.me/contest/1535/problem/B

#include<bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        int ans = 0;
        cin >> n;
        int a[n+5];
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }

        for (int i = 1; i <= n; i++) {
            for (int j = i+1; j <= n; j++) {
                if (__gcd(a[i], a[j]*2) + __gcd(a[i]*2, a[j]) > 2) ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

I can't understand why this is an accepted solution.

Even when here we are counting two times 1) gcd(2*a[j],a[i]) 2) gcd(2*a[i],a[j])

Answer should have been something else.

In other words what is the need to see the two times the gcd ??

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By vedantsharma2508, history, 5 months ago, In English

Dear Community

I have started CP for quite some time but feel that when I write a few lines of code, I always have to debug it. There always in some way or the other bugs come in my code. Can anyone give practical actionable tips to get out of this problem.

Regards Vedant

Full text and comments »

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

By vedantsharma2508, history, 5 months ago, In English

I am new to competitive programming and I was trying out this problem.

Problem https://cses.fi/problemset/task/2183.

Looked up many places on the internet but still I am unable to understand it.

Can anyone help me with same. Regards

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it