Pagini recente » Cod sursa (job #2883639) | Cod sursa (job #3192975) | Cod sursa (job #1967635) | Cod sursa (job #1778205) | Cod sursa (job #1394730)
#include <fstream>
#include <vector>
using namespace std;
class nrm {
public:
vector<int> v;
nrm () {
v.push_back (0);
}
nrm (int x) {
while (x)
v.push_back (x%10),
x /= 10;
}
void operator = (int x) {
v.clear ();
while (x)
v.push_back (x%10),
x /= 10;
}
void operator *= (nrm b) {
vector<int> c;
for (int i = 0; i < v.size (); i++)
for (int j = 0, t = 0, val; j < b.v.size () || t; j++, t /= 10) {
val = (t += v[i] * b.v[j]) % 10;
if (i + j >= c.size ())
c.push_back (val);
else
c[i+j] += val;
}
v.clear ();
v = c;
}
friend ostream& operator<< (ostream& fout, const nrm x) {
for (int i = x.v.size ()-1; i >= 0; i--)
fout << x.v[i];
return fout;
}
};
int main()
{
ifstream fin ("patrate2.in");
ofstream fout ("patrate2.out");
int n;
fin >> n;
nrm n4 (1), fact (1), four(4);
for (int i = 1; i <= n; i++) {
nrm x (i);
fact *= x;
n4 *= four;
}
fact *= n4;
fout << fact;
return 0;
}