hdoj2011_多项式求和
来源:互联网 发布:淘宝助理怎么查看订单 编辑:程序博客网 时间:2024/05/12 22:16
import java.util.Scanner;
import java.lang.Math;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
int n=in.nextInt();
for(int i=0;i<n;i++){
int m=in.nextInt();
double sum=0;
for(int j=1;j<=m;j++)
sum+=Math.pow(-1.0,j+1.0)/j;
System.out.printf("%.2f",sum);
System.out.println();
}
}
}
}
import java.lang.Math;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
int n=in.nextInt();
for(int i=0;i<n;i++){
int m=in.nextInt();
double sum=0;
for(int j=1;j<=m;j++)
sum+=Math.pow(-1.0,j+1.0)/j;
System.out.printf("%.2f",sum);
System.out.println();
}
}
}
}
阅读全文
0 0
- hdoj2011_多项式求和
- 多项式求和
- 多项式求和
- 多项式求和
- 多项式求和
- 多项式求和
- 多项式求和
- 多项式求和
- 多项式求和
- 多项式求和
- 多项式求和
- 多项式求和
- 多项式求和
- 多项式求和
- 多项式求和
- 多项式求和
- 多项式求和
- 多项式求和
- RxJava之Subject分类解析
- 防止SQL注入的五种方法
- OKHttp_POST和Get 请求
- sublime 的key binding 设置删除行
- PAT(Basic Level)_1026_程序运行时间
- hdoj2011_多项式求和
- Python中file()和open()的区别
- LeetCode(19)--Remove Nth Node From End of List
- Wireless Network
- js(jQuery)获取时间的方法及常用时间类
- CodeForces 580 D.Kefa and Dishes(状压DP)
- 分页--第十九天
- Effective C++之Item 10: 让assigment operator(赋值运算符)返回一个reference to *this
- spring、hibernate整合核心配置文件applicationContext.xml