Добавил программы по тестированию
This commit is contained in:
31
programs/2_exponentiation.cpp
Normal file
31
programs/2_exponentiation.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned long long n, k;
|
||||
|
||||
cin >> n >> k;
|
||||
|
||||
if (n < 1 || n > 15 || k < 1 || k > 15)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned long long r = 1;
|
||||
|
||||
while (k > 0)
|
||||
{
|
||||
if (k % 2 == 1)
|
||||
{
|
||||
r *= n;
|
||||
}
|
||||
n *= n;
|
||||
k /= 2;
|
||||
}
|
||||
|
||||
cout << r << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user