杭电oj 1001


#include<iostream>
using namespace std;
int main()
{
int n = 0, sum;
while (cin>>n)
{
sum = 0; // 这里要清零
for (int i =0; i <= n; i++)
{
sum += i;
}
cout << sum <<endl <<endl;
}
return 0;
}

杭电oj 1001

时间: 2024-08-12 05:37:20

杭电oj 1001的相关文章

【转】对于杭电OJ题目的分类

[好像博客园不能直接转载,所以我复制过来了..] 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDI

杭电oj 1002

1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 int nCases; 5 int m[1001], n[1001]; 6 char a[1001], b[1001]; 7 int main() 8 { 9 scanf("%d", &nCases); 10 for(int i = 1; i <= nCases; ++i) 11 { 12 memset(m,

杭电oj 1106

排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 74104    Accepted Submission(s): 22754 Problem Description 输入一行数字,如果我们把这行数字中的'5'都看成空格,那么就得到一行用空格分割的若干非负整数(可能有些整数以'0'开头,这些头部的'0'应该被忽略掉,除非这个整数就是由

杭电oj 1009 FatMouse&#39; Trade

Tips:本题采用贪心算法,类似于背包问题,关键在于读入数据之后,将数据按 J[i]/F[i] 从大到小排列即可. 1 /**本程序主要采用贪心算法思想,类似于背包问题*/ 2 #include<stdio.h> 3 #include<string.h> 4 int main() 5 { 6 int M,N; 7 while(scanf("%d %d",&M,&N)) 8 { 9 if(M == -1 && N == -1) 10

异或^符号在C/C++中的使用 &amp; 杭电oj 2095

异或^符号,在平时的学习时可能遇到的不多,不过有时使用得当可以发挥意想不到的结果. 值得注意的是,异或运算是建立在二进制基础上的,所有运算过程都是按位异或(即相同为0,不同为1,也称模二加),得到最终结果. 特点:任何数和0异或都等于它本身;两个相同的数异或后的结果是0: 举例如下: int a = 4 =100(二进制) int b = 3 =011(二进制) int c = a^b = 111 = 7: 下面就^常用应用做个介绍: 1. 在一排数中找到独一无二的一个数 本例启发来自于杭电oj

杭电OJ(HDU)-ACMSteps-Chapter Two-《An Easy Task》《Buildings》《decimal system》《Vowel Counting》

http://acm.hdu.edu.cn/game/entry/problem/list.php?chapterid=1§ionid=2 1.2.5 #include<stdio.h> /* 题意:找闰年. if((i%4==0 && i%100!=0) || i%400==0)count++; 3 2005 25 1855 12 2004 10000 2108 1904 43236 */ int main() { int t,y,n; int i,count=0; whil

杭电OJ(HDU)-ACMSteps-Chapter Three-《FatMouse&amp;#39; Trade》《今年暑假不AC》《排名》《开门人和关门人》

http://acm.hdu.edu.cn/game/entry/problem/list.php?chapterid=1§ionid=3 1.3.1 FatMouse' Trade #include <algorithm> /* 题意:价值/代价的比值来排序,买比值大的. Sample Input 5 3 7 2 4 3 5 2 20 3 25 18 24 15 15 10 -1 -1 Sample Output 13.333 31.500 */ #include<stdio.h>

杭电oj 1069 Monkey and Banana

Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6866 Accepted Submission(s): 3516 Problem Description A group of researchers are designing an experiment to test the IQ of a monkey

杭电OJ(HDU)-ACM Steps-Chapter Two-《Biker&#39;s Trip Odometer》《Climbing Worm》《hide handkerchief》《Nasty Hac》

1.2.1 Biker's Trip Odometer #include<stdio.h> #include<math.h> const double PI=acos(-1.0); /* 计算题,根据公式做就行,PI*d*r/(12*5280);res1/t*3600; Sample Input 26 1000 5 27.25 873234 3000 26 0 1000 Sample Output Trip #1: 1.29 928.20 Trip #2: 1179.86 1415