nyoj 122 Triangular Sums
Triangular Sums
- 描述
-
The nth Triangular number, T(n) = 1 + … + n, is the sum of the first n integers. It is the number of points in a triangular array with n points on side. For example T(4):
X
X X
X X X
X X X XWrite a program to compute the weighted sum of triangular numbers:
W(n) =
SUM[k = 1…n; k * T(k + 1)]
- 输入
-
The first line of input contains a single integer N, (1 ≤ N ≤ 1000) which is the number of datasets that follow.
Each dataset consists of a single line of input containing a single integer n, (1 ≤ n ≤300), which is the number of points on a side of the triangle.
- 输出
- For each dataset, output on a single line the dataset number (1 through N), a blank, the value of n for the dataset, a blank, and the weighted sum ,W(n), of triangular numbers for n.
- 样例输入
-
4 3 4 5 10
- 样例输出
-
1 3 45 2 4 105 3 5 210 4 10 2145
- 来源
- Greater New York 2006
-
上传者
张云聪这是道阅读题 英语不好是硬伤
思路 :T(N)=1+2+3+.....+N ; SUM=1*T(2)+2*T(3)+3*T(4)+......N*T(N+1)(注意:b[1]=a[2])
-
#include<stdio.h> int main() {int a[305],b[305],t,c=1;;scanf("%d",&t);a[0]=1;for(int i=1;i<=305;i++)a[i]=i*(i+1)/2;b[1]=a[2];for(int i=2;i<=300;i++)b[i]=b[i-1]+a[i+1]*i;while(t--){int n;scanf("%d",&n);printf("%d %d %d\n",c++,n,b[n]);}return 0; }
nyoj 122 Triangular Sums相关推荐
- Triangular Sums http://acm.nyist.net/JudgeOnline/problem.php?pid=122
Triangular Sums 时间限制:3000 ms | 内存限制:65535 KB 难度:2 描述 The nth Triangular number, T(n) = 1 + - + n, ...
- Triangular Sums
Triangular Sums 时间限制:3000 ms | 内存限制:65535 KB 难度:2 描述 The nth Triangular number, T(n) = 1 + - + n, ...
- 【NYOJ 分类——语言入门】——汇总(四)
题目113 题目信息 运行结果 本题排行 讨论区 字符串替换 时间限制:3000 ms | 内存限制:65535 KB 难度:2 描述 编写一个程序实现将字符串中的所有"you" ...
- poj入门水题整理1--按刷题顺序解释
1.1000 A+B 就是熟悉平台的一道题,下面有案例 2.1004 Financial Management 描述: Larry毕业之后挣钱了想知道他的财务状况,他现在有他的存款清单,想知道他12个 ...
- HOJ题目分类//放这儿没事刷刷学算法!嘻嘻!
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
- [Swift]LeetCode373. 查找和最小的K对数字 | Find K Pairs with Smallest Sums
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ ➤微信公众号:山青咏芝(shanqingyongzhi) ➤博客园地址:山青咏芝(https://www.cnblog ...
- usaco ★Subset Sums 集合
★Subset Sums 集合 对于从 1 到 N 的连续整集合合,能划分成两个子集合,且保证每个集合的数字和是相等的. 举个例子,如果 N=3,对于{1,2,3}能划分成两个子集合,他们每个的所有数 ...
- 373. Find K Pairs with Smallest Sums (java,优先队列)
题目: You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Def ...
- R计算数组的累计加和(Cumulative Sums)
R计算数组的累计加和(Cumulative Sums) 目录 R计算数组的累计加和(Cumulative Sums) R中的累加和 可视化R中的累加和
- 乐视视频 App 图标改为“欠 122 亿”,网友:我在别家分红包,却在你家随份子!...
作者 | 苏宓 出品 | CSDN(ID:CSDNnews) 不知从何时起,春节成为了各家互联网公司的"高考"以及营销大比拼的另一个"战场". 这不在 2021 ...
最新文章
- phpadmin试用
- 【转】Android编码规范建议18条
- JMeter处理jdbc请求后的响应结果
- 简单的家庭无线路由设置
- 通过测试想到的一些问题
- ORACLE 查询所有表、外键、主键等信息
- ios 渐变透明背景_15张案例,告诉你PPT背景的处理套路
- mysql not in优化_98%的人不知道的MySQL优化器原理
- java10---点餐系统
- cuda必须装在c盘吗_善待你的系统盘——系统盘(C盘)解决方案
- 风变编程python入门经典100题_零基础学Python无压力,风变编程爱了爱了!
- Java判断图片文件格式,不是根据文件后缀判断
- 固定翼位置控制_L1
- kali火狐浏览器设置中文
- JavaScript 数组方法大全
- java得到某时间前2小时的时间
- nodejs之简单的爬数据
- 在线考试系统的倒计时
- mysql日志备份命令是什么_mysql的常用命令以及备份和恢复
- 存在哪些生物信息学子领域?
热门文章
- 戴尔vStart:加快虚拟化,并马上应用戴尔私有云
- CCNP学习笔记第一周
- 计算机是根据用户名,根据用户名移动计算机账号
- postgresql立式版本下载_Apache ShardingSphere 4.1.1版本正式发布
- python人脸识别程序如何嵌入到app_开源|手把手教你用Python进行人脸识别(附源代码)...
- 地脚螺钉直径系列_干数控这么久,现在才分清楚螺栓、螺钉、螺柱的区别
- linux zip压缩比1000,linux下压缩工具总结与使用(参考私房菜)
- 利用hasOwnProperty实现的高效的javascript hashtable
- 查询ubuntu系统版本相关信息
- 操作系统就是虚拟机--主内又主外