Sum Problem
In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n. Input The input will consist of a series of integers n, one integer per line. Output For each case, output SUM(n) in one line, followed by a blank line. Code #include<stdio.h>
int main()
{
int i,n,sum;
while(scanf("%d",&n)!=EOF)
{
sum=0;
for(i=1;i<=n;i++)
sum+=i;
printf("%d\n\n",sum);
}
return 0;
}
Sum Problem
相關推薦
NYOJ 927 The partial sum problem 【DFS】+【剪枝】
har int 輸出 amp lines cmp dsm sim pri The partial sum problem 時間限制:1000 ms | 內存限制:65535 KB 難度:2 描寫敘述One day,Tom’s
[Coding Made Simple] Subset Sum Problem
sel fin .com ... run time cti pro ini Given a set of non negative integers and a target value, find if there exists a subset in the given
題解報告:hdu 2058 The sum problem
show AC out 求和 pan post 思考 its 題解報告 題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=2058 問題描述 給定一個序列1,2,3,...... N,你的工作是計算所有可能的子序列,其子序列的
HDU - 2058 - The sum problem
total orm back spa ins gpo 大於 2.0 ... The sum problem Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
動態規劃法(三)子集和問題(Subset sum problem)
慢慢 們的 遞歸法 found swe otto 題目 子集和問題 自己的 ??繼續講故事~~ ??上次講到我們的主人公丁丁,用神奇的動態規劃法解決了雜貨店老板的兩個找零錢問題,得到了老板的肯定。之後,他就決心去大城市闖蕩了,看一看外面更大的世界。 ??這天,丁丁剛回到家,
Sum Problem
problem turn out per ... ase tle scanf panel Problem DescriptionIn this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.
HDU2058-The sum problem
HDU2058-The sum problem 題目: Problem Description Given a sequence 1,2,3,…N, your job is to calculate all the possible sub-sequences that the su
HDU 2058 - The sum problem(等差數列)
The sum problem Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 30916&n
The partial sum problem (DFS)nyoj
The partial sum problem 時間限制:1000 ms | 記憶體限制:65535 KB 輸入 There are multiple test cases. Each test case contains three lines.The first
HDU 2058:The sum problem(數學)
The sum problem Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
HDU 2058 The sum problem 題解
由題意得: 1.輸入第一個數“n”,作為首項與公差都為“1”的末項 2.輸入第二個數“m”,輸出序列和為“m”的所有子序列,既找到首項“a1”與項數"len" 3.由等差數列求和公式 S=n*(a1+an)/2=a1*n+n*(n-1)*d/2 得:a1*len=m-len*(le
Sum Problem --JAVA
題目: Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge). In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... +
Summary_(hdu 2058)_(The Sum Problem)
第一次的話,超時是肯定要的/哭 大致思路:運用等差數列求和公式。 Sn = a1n+n(n-1)d/2. 此題中 d = 1. 即 Sn = a1n+n*(n-1)/2. 根據 n >=1 存在不等式2m<=n*n a1 n = Sn - n(n
HDU 1001Sum Problem (java)
Sum Problem Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 517127 Accepted S
杭電acm2058————The sum problem(C語言)
原題: Problem Description Given a sequence 1,2,3,……N, your job is to calculate all the possible sub-sequences that the sum of the
OJ-HDU The sum problem
The sum problem Time Limit: 5000/1000 MS (Java/Others) Memory Li
HUD-1001 Sum Problem 解題報告
題目很簡單 需要注意的是,在輸出中要求每行輸出間有一個空行 如果沒有注意到這點,很容易出現Presentation Error(格式錯誤) 即 PE 題目給出的輸出範圍為32位,所以int就可以解決該問題 解決了這些問題,就可以解題了 比較直接的方法就是暴力迴圈累加
杭電2058 The sum problem
The sum problem Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 19582 Accept
The Maximum Subsequence Sum Problem
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">本文來自CSCI 3320/8325 Data Structures,對