【HDOJ】5203 Rikka with wood sticks

 /* 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 ;
}
上一篇:Bash Shell内建命令和保留字


下一篇:ExtJS MVC学习手记 2