Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- vector<int>x;
- vector<int> times (vector<int> x, int y);
- vector<int> factorial (int n);
- vector<int> pow(int n);
- void write(vector<int> x);
- int main()
- {
- int a;
- cin>>a;
- pow(a);
- write(x);
- return 0;
- }
- void write(vector<int> x)
- {
- reverse(x.begin(), x.end());
- if (x.size()==0)
- {
- cout<<"gol"<<endl;
- }
- else
- {
- for(auto const it : x)
- {
- cout<<it;
- }
- }
- }
- vector<int> times (vector<int> a, int y)
- {
- vector<int> aux;
- int t=0;
- for(int i=0; i<a.size(); i++)
- {
- t=t+x[i]*y;
- aux.push_back(t%10);
- t/=10;
- }
- while (t>0)
- {
- aux.push_back(t%10);
- t/=10;
- }
- return aux;
- }
- vector<int> factorial (int n, vector<int> &aux)
- {
- aux.push_back(1);
- for(int i=1; i<=n; i++)
- {
- aux=times(x,i);
- }
- return aux;
- }
- vector<int> pow(int n)
- {
- factorial(n,x);
- for(int i=1; i<=n; i++)
- {
- x=times(x,n);
- }
- return x;
- }
Advertisement
Add Comment
Please, Sign In to add comment