Kick start Round B 2022 Palindromic Factors Solution



Kick start Round B 2022  Palindromic Factors Solution 


Problem Link: 

  https://codingcompetitions.withgoogle.com/kickstart/round/00000000008caa74/0000000000acee89 

Solution in C++: 

///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat  Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
///**********ALLAH IS ALMIGHTY************///
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long   c,n,x,y,t,r,i,j=0,mx;
    cin>>t;
    while(t--)
    {
        c=0;
        string s,r;
        vector<long long>v;
        cin>>n;
        for ( i=1; i<=sqrt(n); i++)
        {
            if (n%i == 0)
            {

                if (n/i == i)
                    v.push_back(i);

                else
                    v.push_back(i),v.push_back(n/i);
            }
        }
        sort(v.begin(),v.end());
        for(i=0;i<v.size(); i++)
        {
            if(v[i]==0)
                continue;
            s = to_string(v[i]);
            r=s;
            reverse(s.begin(),s.end());
            if(r==s)
                c++;
        }
        printf("Case #%lld: %lld\n",++j,c);
    }
}






No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.