Cod sursa(job #1358359)
Utilizator | Data | 24 februarie 2015 16:08:14 | |
---|---|---|---|
Problema | Invers modular | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.56 kb |
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
int main ()
{
int x, y, p, i;
p = 1;
f >> x >> y;
i = x;
for(int a = 2; a < y; a++)
{
if(y % a != 0)
{
p++;
}
}
for(int a = 1; a < (p-1); a++)
{
x = x * i;
cout << x << endl;
}
g << x % y;
}