HDU5203 Rikka with wood sticks
来源:互联网 发布:彩妆淘宝店找货源 编辑:程序博客网 时间:2024/05/17 09:44
Problem Description
As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:
Yuta have a wood stick of lengthn which consists of n linked sticks of length 1 . So it has n−1 connection points. Yuta finds that some sticks of length 1 of the wood stick are not strong. So he wants to choose three different connection points to cut it into four wood sticks and only one of them contains wood sticks which are not strong. And Yuta wants to minimize the length of this piece which contains bad wood sticks. Besides, Rikka wants to use the other three wood sticks to make a triangle. Now she wants to count the number of the ways to cut the wood sticks which can make both Yuta and herself happy.
It is too difficult for Rikka. Can you help her?
Yuta have a wood stick of length
It is too difficult for Rikka. Can you help her?
Input
This problem has multi test cases (no more than 20 ). For each test case, The first line contains two numbers n,m(1≤n≤1000000,1≤m≤1000) . The next line contains m numbers (some of them may be same) – the position of each wood sticks which is not strong.
Output
For each test cases print only one number – the ways to cut the wood sticks.
Sample Input
6 135 13
Sample Output
20
Source
BestCoder Round #37 ($)
Recommend
hujie | We have carefully selected several similar problems for you: 5205 5204 5201 5200 5199
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<queue>#include<stack>#include<vector>#include<set>#include<map>#define L(x) (x<<1)#define R(x) (x<<1|1)#define MID(x,y) ((x+y)>>1)#define eps 1e-8typedef long long ll;#define fre(i,a,b) for(i = a; i <b; i++)#define free(i,b,a) for(i = b; i >= a;i--)#define mem(t, v) memset ((t) , v, sizeof(t))#define ssf(n) scanf("%s", n)#define sf(n) scanf("%d", &n)#define sff(a,b) scanf("%d %d", &a, &b)#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)#define pf printf#define bug pf("Hi\n")using namespace std;#define INF 0x3f3f3f3f#define N 400int n,m;int le,ri;int a,b;void fdd(){ a=a+b; int i,j; ll ans=0; for(i=1;i*2<a;i++) { int t=a-i-i; t/=2; t++; int to=a-i-t; if(to<t) continue; if(t==0) continue; ans+=to-t+1; } pf("%I64d\n",ans);}int judge(int x,int y,int z){ if(x+y<=z||x+z<=y) return 0; return 1;}void solve(){ int i,j; if(a==0||b==0){fdd();return ;} ll ans=0; if(a>b) swap(a,b); for(i=1;i<b;i++){if(judge(a,i,b-i))ans++;} printf("%I64d\n",ans);}int main(){ int i,j; while(~scanf("%d%d",&n,&m)) { le=INF; ri=-1; int x; while(m--){sf(x);le=min(le,x);ri=max(ri,x);} a=le-1; b=n-ri; if(a==b) { pf("0\n"); continue; } solve(); } return 0;}/*8 11*/
0 0
- HDU5203 Rikka with wood sticks
- Rikka with wood sticks
- HDU 5203 Rikka with wood sticks
- HDU - 5203 Rikka with wood sticks 分析
- hdu 5203 Rikka with wood sticks
- hdu 5203 Rikka with wood sticks
- hdu 5203 Rikka with wood sticks
- HDU 5203 Rikka with wood sticks
- BestCoder #37 Rikka with wood sticks DFS暴力
- hdu 5203 Rikka with wood sticks (暴力枚举边)
- hdu 5203 Rikka with wood sticks(Bestcoder Round #37)
- hdu5203
- bestcoder Rikka with string
- Rikka with string
- hdu5204-Rikka with sequence
- HDU5202 Rikka with string
- hdu5202 Rikka with string
- Rikka with Graph
- 扩展欧几里得定理——POJ 1061
- GPS数据格式的分析与处理
- iNode
- 细说 ASP.NET控制HTTP缓存--浏览器缓存
- UVA - 10815 Andy's First Dictionary
- HDU5203 Rikka with wood sticks
- java代码实现商品类别的无限级分类显示
- SQL Server查询分页技术
- Apache 配置虚拟
- 怎么理解并发多进程服务和多线程服务器
- C++数据结构之链表
- 关于我的新网站
- myeclipse报错An error has occurred. See error log for more details. com/genuitec/eclipse/j2eedt/core/J
- 步步为营_Android开发课[21]_用户界面之Notification(通知栏)