山東科技大學OJ//求1+2+3+……+n

 這題的HINT提示要我們注意數據範圍,我們不妨就設定數據範圍爲unsigned long long 類型,這個等差數列求和公式在高中就已經學過,大家這麼聰明肯定知道的啦。 #include<stdio.h> int main() { unsigned long long int n,s; s=0; scanf ("%llu",&n); s=n+n*(n-1)/2;
相關文章
相關標籤/搜索