e156. 良心題: 求和
Tags : 函式指標 建構函式 樣板 虛擬函式 遞迴
Accepted rate : 2027人/2088人 ( 97% ) [非即時]
評分方式:
Tolerant

最近更新 : 2020-03-22 11:16

Content

如何不用乘法、除法、<<、>>、~、^,也不用for、while、if、else、switch、case及三元運算子,算出1+2+3+...+n ?

Input

輸入只有一個正整數n。

1<=n<=1000

Output

請輸出1+2+3+...+n的結果。

Sample Input #1
3
Sample Output #1
6
Sample Input #2
4
Sample Output #2
10
測資資訊:
記憶體限制: 512 MB
公開 測資點#0 (16%): 0.2s , <1K
公開 測資點#1 (16%): 0.2s , <1K
公開 測資點#2 (17%): 0.2s , <1K
公開 測資點#3 (17%): 0.2s , <1K
公開 測資點#4 (17%): 0.2s , <1K
公開 測資點#5 (17%): 0.2s , <1K
Hint :

在你送出用了上述關鍵字的code時,請先摸著自己的良心。

Tags:
函式指標 建構函式 樣板 虛擬函式 遞迴
出處:
[管理者: qqrainbow (愛蜜莉雅) ]

Status Forum 排行

ID User Problem Subject Hit Post Date
38462 aquariumchen ... (Bruh) e156
python 速解提示
26 2023-11-25 22:17
37932 qscfth374@gm ... (._.) e156
python提示
49 2023-10-19 12:15
37662 ericshen1955 ... (暴力又被TLE) e156
77 2023-09-25 20:10
29837 wer12369qaz1 ... (dentr) e156
1+2+3+....n 公式
816 2022-04-04 19:16
27390 kaehsu (Bothsides) e156
"真"良心寫法
984 2021-09-30 02:20