回答編集履歴

3

何度も修正申し訳ないです

2015/05/19 01:24

投稿

swordone
swordone

スコア20651

test CHANGED
@@ -54,7 +54,7 @@
54
54
 
55
55
  public static int f(int m,int n){
56
56
 
57
- return 2 * (Math.abs(m - n) + 1) * (m + n) / 2;
57
+ return (Math.abs(m - n) + 1) * (m + n) / 2;
58
58
 
59
59
  }
60
60
 

2

再修正

2015/05/19 01:24

投稿

swordone
swordone

スコア20651

test CHANGED
@@ -54,7 +54,7 @@
54
54
 
55
55
  public static int f(int m,int n){
56
56
 
57
- return 2 * (Math.abs(m - n + 1)) * (m + n) / 2;
57
+ return 2 * (Math.abs(m - n) + 1) * (m + n) / 2;
58
58
 
59
59
  }
60
60
 

1

公式を修正

2015/05/19 01:23

投稿

swordone
swordone

スコア20651

test CHANGED
@@ -54,7 +54,7 @@
54
54
 
55
55
  public static int f(int m,int n){
56
56
 
57
- return (m + n) / 2;
57
+ return 2 * (Math.abs(m - n + 1)) * (m + n) / 2;
58
58
 
59
59
  }
60
60