Skip to content

Instantly share code, notes, and snippets.

@sparkingdark
Forked from therohitdas/all code.md
Last active July 1, 2020 09:08
Show Gist options
  • Save sparkingdark/ecef4f7a05c672a1c87cf0f4ec7e0724 to your computer and use it in GitHub Desktop.
Save sparkingdark/ecef4f7a05c672a1c87cf0f4ec7e0724 to your computer and use it in GitHub Desktop.

F

#include <bits/stdc++.h>

using namespace std;

int main()
{
    long sum = 0;

    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        long in;
        cin >> in;
        in = (long)pow(2, in);
        string str = to_string(in);
        str = str.length() > 2 ? str.substr(str.length() - 2) : str;
        in = stoi(str);
        sum += in;
    }

    cout << sum % 100 << endl;

    return 0;
}

Prob E

#include<bits/stdc++.h>
#define ll long long int

using namespace std;

bool isPerfectSquare(long double x) 
{   
  // Find floating point value of  
  // square root of x. 
  long double sr = sqrt(x); 
  
  // If square root is an integer 
  return ((sr - floor(sr)) == 0); 
} 
  
bool divisible_perfect(int num){
  int flag = 0;
for(ll i = 2; i < num; i++){
    if ( num % (i*i) == 0){
        return true;
        flag = 1;
        break;
    }
}
if(flag == 0){
    return false;
}

}  

int square_free_number_check(int num){
    ll count = 0;
    vector<int> store;

    for(ll i = 2;i<num;i++){
        if(num%i == 0 && !isPerfectSquare(i)){
          store.push_back(i);
        }
    }

    for(auto i:store){
      if(num % i == 0 && !divisible_perfect(i)){
        cout<<i<<endl;
        count++;
      }
    }

    return count;
}

int main(int argc, char const *argv[])
{
  ll N;
  cin>>N;
  cout<<square_free_number_check(N);
  return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment