Sort by

recency

|

51 Discussions

|

  • + 0 comments

    Thanks for sharing such a valuable code it helps me alote on yellow liquid hope i can utilize it more.

  • + 0 comments

    con anyone fix my c++ solution please

    string solve(int n) {
        int x = 0;
        int pl =0;
        for(int i = 1; i<n/2+1;i++){
            if(n%i==0){
                x++;
                if(i%2==0){
                    if(sqrt(i) == (int)sqrt(i)){
                        pl++;
                    }
                }
            }
        }
        if(pl == 0){
            return to_string(0);
        }
        return (to_string(pl)+"/"+to_string(x));
    }
    
  • + 0 comments

    Your code helped me a lot. five nights at freddy's

  • + 0 comments

    Great work on the coding. I also such amazing coding snippets on Legal Founders articles.

  • + 1 comment

    C# - I wouldn't name it hard...

    private static int[] quads = new int[498].AsEnumerable().Select((n, i) => 4 * (i + 1) * (i + 1)).ToArray();
    private static int GCD(int a, int b)
    {
        return a == 0 ? b : GCD(b % a, a);
    }
    private static bool contains(int div)
    {
        int left = 0, right = 497;
        do
        {
            if (quads[left] == div || quads[right] == div) return true;
            int mid = (left + right) / 2;
            if (quads[mid] < div) left = mid;
            else right = mid;
        }
        while (left < right - 1);
        return quads[left] == div || quads[right] == div;
    }
    private static int getDivs(int n, out int evn)
    {
        int cnt = 1;
        evn = 0;
        for (int i = 2; i <= (int)Math.Sqrt(n); i++)
        {
            if (n % i == 0)
            {
                cnt += n / i == i ? 1 : 2;
                if(contains(i)) evn++;
                if(n / i != i && contains(n/i)) evn++;
            }
        }
        return cnt;
    }
    public static string solveEvenQuadDiv(int n)
    {
        if (n < 8 || n % 4 != 0) return "0";
        int tot = getDivs(n, out int evn);
        int gcd = GCD(evn, tot);
        return $"{evn/gcd}/{tot/gcd}";
    }
    

    ...though some guess is required