武汉科技大学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: ...
随机推荐
- Tomcat基础教程(三)
Tomcat中的Web应用 Web应用就是具有特定目录结构的目录和文件. 基于JAVA技术开发的Web应用中通常会包含以下的web对象: 静态文件对象:HTML页面,图片,普通文件 Servlet: ...
- PostBack与IsPostBack区别
这涉及到aspx的页面回传机制的基础知识 postback是回传 即页面在首次加载后向服务器提交数据,然后服务器把处理好的数据传递到客户端并显示出来,就叫postback, ispostback只是一 ...
- Heapsort 堆排序算法详解(Java实现)
Heapsort (堆排序)是最经典的排序算法之一,在google或者百度中搜一下可以搜到很多非常详细的解析.同样好的排序算法还有quicksort(快速排序)和merge sort(归并排序),选择 ...
- ExtJs MVC应用架构示例
项目目录结构 (源码)2. app.js Ext.Loader.setConfig({ enabled : true, paths : { 'Ext' : 'extjs', 'App' : 'app' ...
- android环境下两种md5加密方式
在平时开发过程中,MD5加密是一个比较常用的算法,最常见的使用场景就是在帐号注册时,用户输入的密码经md5加密后,传输至服务器保存起来.虽然md5加密经常用,但是md5的加密原理我还真说不上来,对md ...
- HDOJ(HDU) 2060 Snooker(英语很重要。。。)
Problem Description background: Philip likes to play the QQ game of Snooker when he wants a relax, t ...
- 【转】Contrary to the answers here, you DON'T need to worry about encoding!
For those goals, I honestly do not understand why people keep telling you that you need the encoding ...
- LeetCode-Add Two Binary
Add BinaryApr 2 '12 3558 / 10570 Given two binary strings, return their sum (also a binary string). ...
- 重写扫雷(基于jQuery) 新手 有不足的地方敬请谅解
记得刚开始学习js的时候写过一次扫雷,一个下午的时间被计算搞死,整个头是晕乎. 入职后,蹭着空闲的时间随手写了一个扫雷. 直接上代码了 (function() { function module() ...
- 修改CKFinder上传路径
一.CKFinder的若干问题 1.单独使用 ckfinder从原fckeditor分离出来以后可以单独使用,通常我习惯于在工具栏中添加ckfinder.dll,这样以后要使用ckfinder直接从工 ...