杭州電子科技大學acm 2011

2021-07-05 06:38:20 字數 626 閱讀 6586

problem description

多項式的描述如下:

1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 + ...

現在請你求出該多項式的前n項的和。

input

輸入資料由2行組成,首先是乙個正整數m(m<100),表示測試例項的個數,第二行包含m個正整數,對於每乙個整數(不妨設為n,n<1000),求該多項式的前n項的和。

output

對於每個測試例項n,要求輸出多項式前n項的和。每個測試例項的輸出佔一行,結果保留2位小數。

#include#include//#includevoid main()

for (int j = 0; j < 1000;j++)

if (j % 2 == 0) //偶數字符號為「+」

a[j] = 1.0*1/(j + 1);

else

a[j] = (-1)*1.0 / (j + 1); //奇數字符號位「-」

for (int i = 0; i < m; i++)

printf("%.2f\n", sum);

}system("pause");

}



杭州電子科技大學ACM 1081

input input consists of several lines of integer numbers.the first line contains an integer n,which is the number of cases to be tested,followed by n ...

杭州電子科技大學acm 2010

problem description 春天是鮮花的季節,水仙花就是其中最迷人的代表,數學上有個水仙花數,他是這樣定義的 水仙花數 是指乙個三位數,它的各位數字的立方和等於其本身,比如 153 1 3 5 3 3 3。現在要求輸出所有在m和n範圍內的水仙花數。input 輸入資料有多組,每組佔一行,...

杭州電子科技大學acm 2005

input 輸入資料有多組,每組佔一行,資料格式為yyyy mm dd組成,具體參見sample input 另外,可以向你確保所有的輸入資料是合法的。output 對於每組輸入資料,輸出一行,表示該日期是該年的第幾天。define crt secure no warnings include in...