含【最小球覆盖】【最大流isap】模板。

题面pdf

https://codeforc.es/gym/101981/attachments/download/7891/20182019-acmicpc-asia-nanjing-regional-contest-en.pdf

 

G---Pyramid【数论】【规律】【递推式】

题意:

度为$n$的Pyramid是一个由$\frac{n(n+1)}{2}$个三角形组成大三角形。比如度为3的Pyramid是下面这样子。

2018ACM-ICPC南京区域赛---AJGIDKM

现在由这些顶点组成等边三角形,问有多少个。

思路:

zyn先放到坐标系里打了个表,然后发现差的差是一个等差数列....

于是就可以有递推关系式了。矩阵快速幂T了

所以只能解方程,把系数解出来。

注意取模求逆元!

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 const ll mod=1e9+7;
 5 ll n;
 6 ll fpow(ll a,ll n)
 7 {
 8     ll res=1,base=a%mod;
 9     while(n)
10     {
11         if(n&1) res*=base, res%=mod;
12         base*=base, base%=mod;
13         n>>=1;
14     }
15     return res%mod;
16 }
17 ll inv(ll a){return fpow(a,mod-2);}
18 int main()
19 {
20     int T;
21     cin>>T;
22     while(T--)
23     {
24         scanf("%I64d",&n);
25         ll ans=0;
26         ans+=fpow(n,4), ans%=mod;
27         ans+=6*fpow(n,3)%mod, ans%=mod;
28         ans+=11*fpow(n,2)%mod, ans%=mod;
29         ans+=6*n%mod, ans%=mod;
30         ans*=inv(24), ans%=mod;
31         printf("%I64d\n",ans);
32     }
33 }
View Code

相关文章:

  • 2022-01-22
  • 2022-12-23
  • 2021-10-22
  • 2021-05-29
  • 2021-07-08
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-17
  • 2022-02-13
  • 2022-12-23
  • 2021-12-03
  • 2021-11-21
相关资源
相似解决方案