CUMTOJ算法实验&数据结构&OJ系统(一)-----快速幂

CUMTOJ算法实验&数据结构&OJ系统(一)-----快速幂

#include 
using namespace std;

long long powerGet(int power)
{
     
	long long inner_result = 1,base;
	base = power;
	while (power>0)
	{
     
		if (power &1) {
     
			inner_result = inner_result* base % 100000007;
		}	
		power >>= 1;
		base = base * base % 100000007;
	}
	return inner_result;
}

int main()
{
     
    //std::cout << "Hello World!\n";
	int n;
	while (cin >> n)
	{
     
		long long result = 1;
		for (int i = 1; i <= n; i++)
		{
     
			result = (result + powerGet(i)) % 100000007;
			//cout << result << ' ';
		}
		cout << result << endl;
	}
}

你可能感兴趣的:(算法,python,算法,数据结构)