Design an algorithm that takes a positive integer N modulus
Solution
#include <iostream>
 #include <vector>
 #include <math.h>
using namespace std;
int base2ToDec(vector <int> b)
 {
    int bb=0;
    int pp=b.size()-1;
    for(int i=0;i<b.size();i++)
    {
        bb+=b.at(i)*pow(2,pp);
        pp--;
    }
    return bb;
 }
long int evaluate(vector <int> nn, vector <int> xx,vector <int> yy)
 {
    long int x=base2ToDec(xx);
    long int y=base2ToDec(yy);
    long int N=base2ToDec(nn);
   return (int)pow(x,y) % N;
 }
int main()
 {
    int myints[] = {1,1,1,1,1,0,0,0,1,1,1,1,0,1};
 vector<int> N(myints, myints + sizeof(myints) / sizeof(int) );
 int xx[]={1,1,0,1,1,1,1,1,1};
 vector <int> x(xx, xx + sizeof(xx) / sizeof(int) );
 int yy[]={0,1,0,1,1,0,0,0,1,1,1,1};
 vector <int> y(yy, yy + sizeof(yy) / sizeof(int) );
    int ans=evaluate(N,x,y);
    cout<<endl<<\"Answer: \"<<ans;
 }

