hdu-5621 KK's Point(dp+数学)
题目链接:
KK's Point
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
For each test case, there are one lines,includes a integer N(2≤N≤10^5),indicating the number of dots of the polygon.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
using namespace std;
typedef long long ll;
const ll mod=1e9+;
const ll inf=1e15;
const int N=1e5+;
int n;
ll dp[N],f[N];
void fun()
{
dp[]=;//注意dp[1] dp[2]的初始化,我在这里就wa了一发;
dp[]=;
dp[]=;
f[]=;
for(int i=;i<N;i++)
{
ll x=(i);
f[i]=f[i-]+x*(x+)/;
}
for(int i=;i<N;i++)
{
dp[i]=dp[i-]++f[i-];
}
}
int main()
{
int t;
scanf("%d",&t);
fun();
while(t--)
{
scanf("%d",&n);
cout<<dp[n]<<"\n";
//printf("%lld\n",dp[n]);
}
return ;
}
hdu-5621 KK's Point(dp+数学)的更多相关文章
- hdu 5621 KK's Point(数学,推理题)
题解: 在圆上点三个点时,除圆上三个交点外,圆内没有交点:在圆上点四个点时,除圆上四个交点外,圆内出现了一个交点,因此,在N个点中每四个点便可以在圆内产生一个交点,因此N个点在圆内形成的点的个数为CN ...
- HDU 5628 Clarke and math dp+数学
Clarke and math 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5628 Description Clarke is a patient ...
- HDU 5622 KK's Chemical DP
题意:bc round 71(中文题面) 分析(官方题解): 根据药品之间的相互关系,我们可以构建一张图,我们对相互会发生反应的药品连边 这个图的特征,是一个环加上一些“树”(可能有多个联通块) 一个 ...
- HDU 5621 KK's Point
N个点中任意选取四个点,就能产生一个圆内的交点,所以圆内总共有C(N,4)个交点,圆上有N个,相加就可以了. 注意:组合数运算的时候会爆longlong,中间先除一下就可以了. #include &l ...
- HDU 1003 Max Sum --- 经典DP
HDU 1003 相关链接 HDU 1231题解 题目大意:给定序列个数n及n个数,求该序列的最大连续子序列的和,要求输出最大连续子序列的和以及子序列的首位位置 解题思路:经典DP,可以定义 ...
- hdu 5094 Maze 状态压缩dp+广搜
作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4092176.html 题目链接:hdu 5094 Maze 状态压缩dp+广搜 使用广度优先 ...
- hdu 2829 Lawrence(斜率优化DP)
题目链接:hdu 2829 Lawrence 题意: 在一条直线型的铁路上,每个站点有各自的权重num[i],每一段铁路(边)的权重(题目上说是战略价值什么的好像)是能经过这条边的所有站点的乘积之和. ...
- hdu 4568 Hunter 最短路+dp
Hunter Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Subm ...
- HDU 1231.最大连续子序列-dp+位置标记
最大连续子序列 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Sub ...
随机推荐
- 邁向IT專家成功之路的三十則鐵律 鐵律十四:IT人言談之道-守中
人與人之間的互動交談最重要的莫過於真誠與頃聽.老子曾在所著的道德經之中,言道:「多言數窮,不如守中」,其意思簡單來說就是不要說多餘的話.人與人之間的相處,常為了一個面子問題,你來我往的爭論不休,其實真 ...
- hadoop常见错误
hadoop常见错误集锦: 1.DataXceiver error processing WRITE_BLOCK operation ERROR org.apache.hadoop.hdfs.serv ...
- Seinfeld(杭电3351)
Seinfeld Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...
- SolidEdge 工程图中如何标注尺寸公差
1 先标注基准框,输入基准符号(A B C之类的) 2 点击特征控制,设置马上要标注的特征和公差(可以保存为模板) 3 直接点击要标注的元素即可 4 没有基准的形位公差标注也一样
- java 发送微信客服消息
package com.baosight.wechat.service; import net.sf.json.JSONObject; import org.apache.commons.httpcl ...
- android 5.2
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2VyZ2V5Y2Fv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA ...
- error MSB8011: 未能注冊输出。请尝试启用“逐用户重定向”
初试MFC就遇到困难了.vs2010创建一个MFC ActiveX控件项目. 什么都还没做呢,就出现故障了? 郁闷呀.! ! 1>C:\Program Files\MSBuild\Microso ...
- .Net 平台WebService的创建、部署和使用介绍
.NET平台内建了对Web Service的支持,包括Web Service的构建和使用.与其它开发平台不同,使用.NET平台,你不需要其他的工具或者SDK就可以完成Web Service的开发了.. ...
- HTML marquee标签
marquee语法 <marquee></marquee> 实例一<marquee>Hello, World</marquee> marquee常 ...
- Java中ASM框架详解
什么是asm呢?asm是assembly的缩写,是汇编的称号,对于java而言,asm就是字节码级别的编程. 而这里说到的asm是指objectweb asm,一种.class的代码生成器的开源项目 ...