Cod sursa(job #1342701)

Utilizator tiberiumunteanMuntean Tiberiu tiberiumuntean Data 14 februarie 2015 13:58:24
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.5 kb

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

#include <fstream>
using namespace std;
int main()
{
    long long baza,putere,rez=1;
    ifstream f("lgput.in");
    f>>baza>>putere;
    f.close();
  long long adun=baza;

   while (putere>0)
   { if (putere%2!=0) rez=(rez*adun)%1999999973;
     adun=(adun%1999999973)*(adun%1999999973)%1999999973;
     putere=putere/2;
     }



  ofstream g("lgput.out");
  g<<rez;
  g.close();
  return 0;
}
    ``