UVA 11401 Triangle Counting(数学)
来源:互联网 发布:mysql 默认 编辑:程序博客网 时间:2024/04/21 00:27
Problem GTriangle Counting
Input: StandardInput
Output: StandardOutput
You are given n rods oflength 1, 2…, n. You have to pick any 3 of them & build a triangle. Howmany distinct triangles can you make? Note that, two triangles will beconsidered different if they have at least 1 pair of arms with differentlength.
Input
The input for each case will have only a single positive integern(3<=n<=1000000). The end ofinput will be indicated by a case withn<3.This case should not be processed.
Output
For each test case, print the number of distinct triangles you canmake.
Sample Input Output for Sample Input
5
8
0
3
22
Problemsetter: Mohammad Mahmudur Rahman
每次做这种三角形的题的时候,我就想到了三角恋,然后就有一种想挖别人墙角的感觉,世界观啊,情商啊,更年期啊。。。看电视剧的时候也是一样,总是支持反派,这情况好像不太正常。。。。(飙泪中。。。)
代码:
#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#define MAXN 1000000+10using namespace std;typedef unsigned long long ULL;ULL a[MAXN];int main(){ a[3] = 0; for(ULL i=4; i<MAXN; i++) { a[i] = a[i-1] + ((i-1)*(i-2)/2-(i-1)/2)/2; } ULL n; while(~scanf("%lld", &n)) { if(n < 3) break; printf("%lld\n", a[n]); } return 0;}
代码有点短是吧,没办法啦,水平有限+更年期,真是不容易啊。。。
- UVA 11401 Triangle Counting(数学)
- Uva - 11401 - Triangle Counting(数学推导)
- UVa 11401 - Triangle Counting (组合数学)
- UVa 11401 Triangle Counting(数学递推)
- UVA Triangle Counting 11401【几何+数学】
- UVA 11401-Triangle Counting-简单数学计算
- UVA-11401 Triangle Counting(数学优化)
- UVA 11401 Triangle Counting
- Uva 11401 - Triangle Counting
- UVA 11401 Triangle Counting
- UVA 11401 - Triangle Counting
- UVA 11401 - Triangle Counting
- uva 11401 - Triangle Counting
- UVA - 11401 Triangle Counting
- UVA 11401 Triangle Counting
- UVA - 11401 Triangle Counting
- uva 11401 Triangle Counting
- UVa 11401 Triangle Counting
- 让Xcode 生成的ipa支持老的iOS设备(armv6)
- 谈深度学习:“知道” 与 “理解”
- 2014 第五届蓝桥杯预赛c/c++本科B组 解题报告
- java btrace
- 不用第三个变量,交换两个变量的值三种方案详解
- UVA 11401 Triangle Counting(数学)
- oracle 创建过程、函数中as, is区别
- 一步步学习微软InfoPath2010和SP2010--第一章节--介绍InfoPath2010(8)--使用模板创建表单实例
- 内部排序之堆排序
- 骑士飞行棋游戏
- new和malloc的区别
- DLL调用
- 解决doxygen绘制函数调用失败问题
- [Linux高级编程]工具&库