Gym - 101981G The 2018 ICPC Asia Nanjing Regional Contest G.Pyramid 找规律

数一个n阶三角形中,有多少个全等三角形,n<=1e9

拿到题想找规律,手画开始一直数漏....,最后还是打了个表

 (打表就是随便定个点为(0,0),然后(2,0),(4,0),(6,0),(1,sqrt(3)),(3,sqrt(3)),(5,sqrt(3)),(2,2*sqrt(3))...)这样

然后枚举三点算

打出来1,5,15,70,126,210,330,495,715,1001,1365,1820,2380,3060,3876

所以ans=(n)*(n+1)*(n+2)*(n+3)

AC代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdlib.h>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
using namespace std;
typedef long long ll;
typedef double ld;
const ll mod=1e9+7;
int t;
ll n,m;
ll ans,temp;
ll qmi(ll m, ll k, ll p)
{
    ll res = 1, t = m;
    while (k)
    {
        if (k&1) res = res * t % p;
        t = t * t % p;
        k >>= 1;
    }
    return res;
}
int main()
{
   scanf("%d",&t);
   while(t--)
   {
       scanf("%lld",&n);
       ans=n*(n+1)%mod*(n+2)%mod*(n+3)%mod;
       temp=qmi(24,mod-2,mod)%mod;
       ans=(ans*temp)%mod;
       printf("%lld\n",ans);
   }
   return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值