Problem G. Pyramid 打表找规律 银牌
https://blog.csdn.net/xiao_you_you/article/details/102076791
1 #include<iostream> 2 #include<cstdio> 3 #include <vector> 4 #include<cmath> 5 #define ll long long 6 #define mod 1000000007 7 using namespace std; 8 ll pow_mod(ll a, ll n) 9 { 10 long long ans = 1; 11 while(n){ 12 if(n&1){ 13 ans = (ans * a) % mod; 14 } 15 a = (a * a) % mod; 16 n >>= 1; 17 } 18 return ans; 19 } 20 21 int main(){ 22 ll n,t; 23 24 scanf("%lld",&t); 25 while(t--){ 26 scanf("%lld",&n); 27 28 ll ans=((((pow_mod(n, 4)+6*pow_mod(n, 3))%mod+11*pow_mod(n, 2))%mod+6*n)%mod)*pow_mod(24, mod-2); 29 ans%=mod; 30 printf("%lld\n",ans); 31 } 32 33 return 0; 34 35 }