UVa 11401
来源:互联网 发布:各种破解软件 编辑:程序博客网 时间:2024/05/17 01:36
题目不难,书上用的是递推,我这里通过解递推式直接出结果
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <ctime>#include <cmath>#include <vector>#include <deque>#include <algorithm>#include <list>#include <map>#include <set>#include <queue>#include <stack>#define REP(i,n) for(int i=0;i<(n);i++)#define REP1(i,n) for(int i=1;i<=(n);i++)#define FOR(i,a,b) for (int i=(a);i<=(b);i++)#define CLR(x,n) memset(x,n,sizeof(x))#define PN printf("\n")#define read(x) scanf("%d",&x)#define read2(x,y) scanf("%d%d",&x,&y)#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)#define write(x) printf("%d",x)#define write1(x) printf("%d ",x)#define writeln(x) printf("%d\n",x)#define write2(x,y) printf("%d %d",x,y)#define writeln2(x,y) printf("%d %d\n",x,y)#define write3(x,y,z) printf("%d %d %d",x,y,z)#define writeln3(x,y,z) printf("%d %d %d\n",x,y,z)#define delta 1e-5#define INF 1<<30#define int64 unsigned long longusing namespace std;int main(){ int64 n; while (scanf("%llu",&n)==1 && n>=3){ n-=3; int64 l2=n/2; int64 l1=n-l2; int64 ans= l1*(l1+1)*(2*l1+1)/6+l2*(l2+1)*(l2+2)/3; printf("%llu\n",ans); } system("pause"); return 0;}
- UVa 11401
- uva 11401
- UVa 11401
- UVA 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 数学
- UVA 11401 Triangle Counting
- UVa 11401 - Triangle Countin
- UVA - 11401 Triangle Counting
- uva 11401 Triangle Counting
- UVa 11401 Triangle Counting
- uva 11401 Triangle Counting
- 拆卸 美能达 50 1.7 手动头
- LeetCode | Remove Duplicates from Sorted Array II
- { 数学 }Catalan数
- 出行留存 (zz)
- 拆卸 美能达 58 1.4
- UVa 11401
- HDOJ 4734 - F(x) 数位DP
- 拆卸 美能达 AF 50 1.7
- MySQL的分层数据管理 无限级分类 设计与优化
- 初识机房收费系统
- 2014年去哪网校园招聘
- 冒泡排序,选择排序,快速排序
- Unix NetWork Programming——环境搭建(解决unp.h等源码编译问题)
- 遇到ios发布AppStore UDID不通过,SDK问题