武汉科技大学ACM :1001: 零起点学算法34——继续求多项式
Problem Description
输入1个正整数n,
计算1+(1+2)+(1+2+3)+...+(1+2+3+...+n)
Input
输入正整数n(多组数据)
Output
输出1+(1+2)+(1+2+3)+...+(1+2+3+...+n)的值(每组数据一行)
Sample Input
2
Sample Output
4
#include<iostream>
using namespace std;
int main()
{
int n,t;
long sum;
while(cin>>n)
{
sum=;
t=;
for(int i=;i<=n;i++)
{
t+=i;
sum+=t;
}
cout<<sum<<endl;
}
return ;
}
其他代码
#include<stdio.h>
int main()
{
int n,sum,i;
while(scanf("%d",&n)!=EOF)
{
for(i=,sum=;i<=n;i++)
sum+=(n-i+)*i;
printf("%d\n",sum);
}
return ;
}
武汉科技大学ACM :1001: 零起点学算法34——继续求多项式的更多相关文章
- Problem E: 零起点学算法34——3n+1问题
#include<stdio.h> #include<math.h> int main() { int n; n<=pow(,); ; scanf("%d&qu ...
- Problem J: 零起点学算法34——3n+1问题
#include<stdio.h> int main() { ; int n; scanf("%d",&n); ) { ==) n=n*+; else n/=; ...
- WUOJ-ACM :1003: 零起点学算法78——牛牛
武汉科技大学ACM :1003: 零起点学算法78--牛牛Problem Description牛牛是一种纸牌游戏,总共5张牌,规则如下: 如果找不到3张牌的点数之和是10的倍数,则为没牛: 如果其中 ...
- 1163: 零起点学算法70——Yes,I can!
1163: 零起点学算法70--Yes,I can! Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: ...
- 1164: 零起点学算法71——C语言合法标识符(存在问题)
1164: 零起点学算法71——C语言合法标识符 Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 10 ...
- 1147: 零起点学算法54——Fibonacc
1147: 零起点学算法54--Fibonacc Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 20 ...
- 1145: 零起点学算法52——数组中删数II
1145: 零起点学算法52--数组中删数II Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 293 ...
- 1137: 零起点学算法44——多组测试数据输出II
1137: 零起点学算法44--多组测试数据输出II Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: ...
- 1136: 零起点学算法43——多组测试数据输出I
1136: 零起点学算法43--多组测试数据输出I Time Limit: 1 Sec Memory Limit: 128 MB 64bit IO Format: %lldSubmitted: ...
随机推荐
- Chrome extension
PageSpeed Tincr SpriteMe JSONView FireMobileSimulator for Google Chrome™
- poj 2031Building a Space Station
http://poj.org/problem?id=2031 #include<cstdio> #include<cstring> #include<cmath> ...
- CentOS 7 ARM 版发布:支持树莓派2/香蕉派/CubieTruck
CentOS 7 ARM 版发布:支持树莓派2/香蕉派/CubieTruck 来自CentOS团队的Karanbir Singh很高兴地宣布,面向ARM硬件架构的CentOS 7 Linux已经正式发 ...
- MapReduce入门
说明 MapReduce是一种分布式计算模型,解决海量数据的计算问题,主要有Map和Reduce组成 用户使用时需要实现map()和reduce()两个函数,两个函数的形参都是key/value键值对 ...
- 调侃Cookie
近期看着某些小朋友那琢急的学习心态,瞬间发文一篇,谨此以助小朋友早日有成! 闲话不扯远,实话见真言,晃悠许久觉得开头还是谈谈Cookie这只菜篮,而且是一只私家菜篮,为啥说它是一只菜篮呢,各位看官必定 ...
- MYSQL转MSSQL
SSMA 2008 for MySQL 1.0.exe SSMA 2008 for MySQL 1.0 Extension Pack.exe mysql-connector-odbc-5.1.11-w ...
- 这是一个在Windows live 上实验的文章
这是一个windows 实验用的文章,希望一次成功
- 持久化API(JPA)系列(三)实体Bean的开发技术-建立与数据库的连接
在EJB 2.x中.EJB有3种类型的Bean.各自是会话Bean(Session Bean).消息驱动Bean(Message-Driven Bean)和实体Bean(Entity Bean). 随 ...
- CVPR读书笔记[5]:Gabor特征提取之Gabor核的实现
朱金华 jinhua1982@gmail.com 2014.08.09 本文參考http://blog.csdn.net/njzhujinhua/article/details/38460861 ...
- Machine Learning—Mixtures of Gaussians and the EM algorithm
印象笔记同步分享:Machine Learning-Mixtures of Gaussians and the EM algorithm