對任意正整數n,空間中的n 個平面最多可將空間切成幾個區域?
輸入說明 :
none
輸出說明 :
none
範例輸入 :
1
2
範例輸出 :
2
4
程式碼 :
#include <stdio.h>
int main()
{
int n;
while(scanf("%d",&n)==1)
printf("%d\n",(n*(n*n+5)/6)+1);
return 0;
}
PS:
空間中任作n個平面,最多將空間分成多少個區域?
ans: (n+1)(n*n-n+6)/6
http://zerojudge.tw/ShowProblem?problemid=a044
沒有留言:
張貼留言