2018 GCPC A题:Chika‘s Math Homework

The question means the square of i* (take i in n) i accumulate from 0 to n


Derivation formulas, combinatorics.


Original code:

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll pow_mod(ll a,ll n,ll m)
{
	if(n==0)
		return 1;
	ll x=pow_mod(a,n/2,m);
	ll ans=x*x%m;
	if(n%2==1)
		years=years*y%m;
	return ans;
}
intmain()
{
	ll n,d=1000000007;
	ll sum=0;
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%lld",&n);
		sum=pow_mod(2,n-1,d);
		sum=(((n%d)*((n+1)%d))/2%d*(sum%d)%d);
		printf("%lld\n",sum);
	}
	return 0;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325481526&siteId=291194637