HDU 5621 KK's Point
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5621
题目翻译
http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=669&pid=1002
题解
很明显,任意取圆上的四个点两两连线,中间会形成一个交点,所以答案是(C_n^4 + n)
然后,从增量的角度,每增加一个点,假设之前有(n)个点,那么这次的增量就是( \left ( n-2 \right ) + \left ( n-3 \right ) \times 2 + … + 1 \times \left ( n-2 \right ) ),如此有技巧的求和也可以得到答案
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
//while(true) RP++; #include<cstdio> #define uLL unsigned long long using namespace std; int n; unsigned long long Ans; inline void solve(int T){ Ans=0; scanf("%d",&n); long long cnt=n-3; for (long long now=1;cnt>0;cnt--,now++) Ans=Ans+(cnt+1)*cnt/2*now; Ans=Ans+n; printf("%llu\n",Ans); } int main(){ int T=0; scanf("%d",&T); for (int i=1;i<=T;i++) solve(i); return 0; } |

原文链接:HDU 5621 KK's Point
WNJXYKの博客 版权所有,转载请注明出处。
还没有任何评论,你来说两句吧!