/* 1002 */
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
using namespace std; const int maxn = 1e3+; int a[maxn], dis[maxn];
int n, m; int main() {
int i, j, k;
int mx, q;
int l1, l2;
int x, y, z, s, tmp;
__int64 ans;
int L, R; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif while (scanf("%d %d", &n, &m) != EOF) {
R = -;
L = n+;
ans = ;
for (i=; i<=m; ++i) {
scanf("%d", &a[i]);
L = min(a[i], L);
R = max(a[i], R);
}
if (L== || R==n) {
s = max(L-, n-R);
for (z=; z<n; ++z) {
if (z >= s-z)
break;
tmp = s-z;
L = (tmp-z)/+;
R = (tmp+z-)/;
ans += (R-L+);
}
printf("%I64d\n", ans);
continue;
}
l1 = L-;
l2 = n-R;
z = l1;
for (x=; x<l2; ++x) {
y = l2-x;
if (x+y>z && y+z>x && z+x>y)
++ans;
}
z = l2;
for (x=; x<l1; ++x) {
y = l1-x;
if (x+y>z && y+z>x && z+x>y)
++ans;
}
printf("%I64d\n", ans);
} #ifndef ONLINE_JUDGE
printf("%d\n", (int)clock());
#endif return ;
}

【HDOJ】5203 Rikka with wood sticks的更多相关文章

  1. hdu.5203.Rikka with wood sticks(数学推导:一条长度为L的线段经分割后可以构成几种三角形)

    Rikka with wood sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/O ...

  2. 【HDOJ】5632 Rikka with Array

    1. 题目描述$A[i]$表示二级制表示的$i$的数字之和.求$1 \le i < j \le n$并且$A[i]>A[j]$的$(i,j)$的总对数. 2. 基本思路$n \le 10^ ...

  3. HDU 5203 Rikka with wood sticks 分类讨论

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5203 bc(chinese):http://bestcoder.hdu.edu.cn/con ...

  4. Rikka with wood sticks(hdu5203)

    Rikka with wood sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/O ...

  5. 【HDOJ】1455 Sticks

    DFS.搜索以棍数为条件循环搜索较好,这样不会超时. #include <stdio.h> #include <string.h> #include <stdlib.h& ...

  6. 【HDOJ】4729 An Easy Problem for Elfness

    其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...

  7. 【HDOJ】【3506】Monkey Party

    DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...

  8. 【HDOJ】【3516】Tree Construction

    DP/四边形不等式 这题跟石子合并有点像…… dp[i][j]为将第 i 个点开始的 j 个点合并的最小代价. 易知有 dp[i][j]=min{dp[i][j] , dp[i][k-i+1]+dp[ ...

  9. 【HDOJ】【3480】Division

    DP/四边形不等式 要求将一个可重集S分成M个子集,求子集的极差的平方和最小是多少…… 首先我们先将这N个数排序,容易想到每个自己都对应着这个有序数组中的一段……而不会是互相穿插着= =因为交换一下明 ...

随机推荐

  1. MyBatis返回主键,MyBatis Insert操作返回主键

    MyBatis返回主键,MyBatis Insert操作返回主键 >>>>>>>>>>>>>>>>> ...

  2. HDU-1114(背包DP)

    Piggy-Bank Problem Description Before ACM can do anything, a budget must be prepared and the necessa ...

  3. jquery判断div是否显示或者隐藏

    jquery判断div是否显示或者隐藏 很多时候会要判断一个div是不是显示着,没显示要怎么处理,显示的如何处理: 方法很简单,选择到你要判断的div,再用is(':hidden')判断是否隐藏:或者 ...

  4. (转)C#中的泛型

    来源:http://www.cnblogs.com/JimmyZhang/archive/2008/12/17/1356727.html .Net 1.1版本最受诟病的一个缺陷就是没有提供对泛型的支持 ...

  5. 2.RABBITMQ 入门 - WINDOWS - 生产和消费消息 一个完整案例

    关于安装和配置,见上一篇 1.RABBITMQ 入门 - WINDOWS - 获取,安装,配置 公司有需求,要求使用winform开发这个东西(消息中间件),另外还要求开发一个日志中间件,但是也是要求 ...

  6. A题笔记(7)

    No. 1468 已知三角形的三条边求面积:海伦公式 S=√[p(p-a)(p-b)(p-c)]   p=(a+b+c)/2 #include <cmath> cmath 是 c++ 语言 ...

  7. js中push()方法

    直接上代码: var roleIdsTemp = []; $("#addRole .modalcheckbox-all").each(function(key, value) {  ...

  8. OC相关-02:oc和c的基本差异

    前言: 面向过程和面向对象. 简单的说,面向过程就是分析出解决问题所需要的步骤,然后用函数把这些步骤一步一步实现,使用的时候一个一个依次调用. 面向对象是把构成问题事务分解成各个对象,建立对象的目的不 ...

  9. 检查.gitignore语法

    每次配置git的时候,要写gitignore文件,你知道你的.gitignore匹配那些文件吗? 看看.gitignore放过了哪些文件: git ls-files -ocm --exclude-st ...

  10. highcharts时间图

    这篇文章适合对highcharts已经有一定了解的猿友. 前两天想用highcharts做一个时间图,但是时间轴(x轴)的时间坐标并不是等间隔的,之前一直采用的方法是把时间做成等间隔的,然后没有数据的 ...