PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CCBCHBA0000047. For khuyết phần init và update (For Without Init and Update Expressions)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
For khuyết phần init và update (For Without Init and Update Expressions)
For Without Init and Update Expressions
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Initialize i=0 before the loop; use for (;i<n;) with an increment in the body to sum integers 0 through n-1.
Input
One integer 0<=n<=1000.
Output
The sum from 0 through n-1.
Subtasks
- Subtask 1 (20%): n<=10.
- Subtask 2 (30%): n<=100.
- Subtask 3 (50%): n<=1000.
Examples
Example 1
Input
5
Output
10
Explanation
0+1+2+3+4=10.
Example 2
Input
0
Output
0
Explanation
The loop body never executes.