#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;
}
Created
July 1, 2020 08:50
-
-
Save therohitdas/933f537889bc15e549d6d4168a8e6c64 to your computer and use it in GitHub Desktop.
G
#include <bits/stdc++.h>
using namespace std;
short unsigned int n;
pair<int, int> destination;
char inp_array[20][20];
pair<int, int> cursor;
bool isValidIndex(pair<int, int> co_ordinate)
{
if ((co_ordinate.first >= 0 && co_ordinate.first < n) && (co_ordinate.second >= 0 && co_ordinate.second < n))
return true;
else
return false;
}
bool isObstacle(short int x, short int y)
{
if ((inp_array[x][y] != 'A') &&
(inp_array[x][y] != 'D') &&
(inp_array[x][y] != 'M') &&
(inp_array[x][y] != 'R') &&
(inp_array[x][y] != 'X'))
return true;
else
return false;
}
void visited(pair<int, int> node)
{
inp_array[node.first][node.second] = 'X';
}
void obstacleList(pair<int, int> node)
{
vector<char> obs;
for (int i = node.first - 1; i <= node.first + 1; i++)
{
for (int j = node.second - 1; j <= node.second + 1; j++)
{
if (isValidIndex(make_pair(i, j)))
{
if (isObstacle(i, j))
{
obs.push_back(inp_array[i][j]);
}
else if (inp_array[i][j] == 'R' || inp_array[i][j] == 'D')
{
cursor = make_pair(i, j);
}
}
}
}
sort(obs.begin(), obs.end());
if (obs.size() == 0)
{
cout << "NO HURDLES" << endl;
}
else
{
for (char a : obs)
{
cout << a << " ";
}
cout << endl;
}
}
void solve()
{
while (cursor != destination)
{
visited(cursor);
obstacleList(cursor);
}
if (cursor == destination)
cout << "DESTINATION" << endl;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
cin >> inp_array[i][j];
if (inp_array[i][j] == 'D')
{
destination = make_pair(i, j);
}
else if ((inp_array[i][j] == 'R') &&
((i == 0 && j == 0) ||
(i == 1 && j == 1) ||
(i == 1 && j == 0)))
{
cursor = make_pair(i, j);
}
}
}
solve();
}
E
--
Follows time limitation. Output time 1s
#include <bits/stdc++.h>
using namespace std;
time_t start, end_time;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
int x, counter = 0;
unordered_set<int> squareFreeFactor;
bool flag = true;
bool isPerfectSquare(int x)
{
return ((floor(sqrt(x)) - sqrt(x)) == 0);
}
unordered_set<int> factor(int a)
{
unordered_set<int> currentFactor;
for (int i = 2; i < a / 2; i++)
{
if (a % i == 0)
{
if (a / i == i)
{
if (!isPerfectSquare(i))
currentFactor.insert(i);
else
flag = false;
}
else
{
if (!isPerfectSquare(i))
currentFactor.insert(i);
else
flag = false;
if (!isPerfectSquare(a / i))
currentFactor.insert(a / i);
else
flag = false;
}
}
}
return currentFactor;
}
void factor_void(int a)
{
for (int i = 2; i < sqrt(a); i++)
{
if (a % i == 0)
{
if (a / i == i)
{
if (isPerfectSquare(i))
flag = false;
}
else
{
if (isPerfectSquare(i))
flag = false;
if (isPerfectSquare(a / i))
flag = false;
}
}
}
}
void solve()
{
unordered_set<int> fac = factor(x);
if (flag)
{
counter++;
}
else
{
flag = true;
}
for (int a : fac)
{
factor_void(a);
if (flag)
{
counter++;
}
else
{
flag = true;
}
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> x;
time(&start);
solve();
cout << counter << endl;
time(&end_time);
cout << double(end_time - start) << "s";
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
//G
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define REP(i,n) for(ll i=0;i<n;i++)
using namespace std;
ll n;
const ll nxm=30;
char a[nxm][nxm];
bool vis[nxm][nxm];
void recur(ll i,ll j)
{
vis[i][j]=1;
if(a[i][j]=='A')
{
}
void solve(){
cin>>n;
ll i1,j1;
REP(i,n) REP(j,n)
{
cin>>a[i][j];
if(a[i][j]=='A')
{
i1=i;j1=j;
}
}
recur(i1,j1);
}
int main(){
solve();
return 0;
}