1 条题解
-
0
C :
#include <stdio.h> int fan(int n) {int h=1,i; i=n/2; if(n==1) return 1; else for(;i>=1;i--) h=h+fan(i); return h;} int main() {int n; scanf("%d",&n); printf("%d",fan(n)); return 0; }
C++ :
#include <iostream> using namespace std; long long f[100001]; long long comp (long long n){ long long s=1,i; for (i=1;i<=n/2;i++){ if (!f[i]) f[i]=comp (i); s+=f[i]; } return s; } int main () { long long n; cin>>n; cout<<comp (n); return 0; }
Pascal :
var n,i,j:longint; p:array[0..10000]of longint; begin readln(n); p[1]:=1; for i:=2 to n do begin for j:=1 to i div 2 do p[i]:=p[i]+p[j]; inc(p[i]); end; writeln(p[n]); end.
Java :
import java.util.*; public class Main{ public static int cnt = 1; public static void main(String[] args) { long startTime = System.currentTimeMillis(); Scanner cin = new Scanner(System.in); int n = cin.nextInt(); recursion(n); System.out.println(cnt); long endTime = System.currentTimeMillis(); // System.out.println(endTime-startTime); } public static void recursion(int n){ for(int i = 1; i <= n/2; i ++){ cnt++; recursion(i); } } }
- 1
信息
- ID
- 207
- 时间
- 1000ms
- 内存
- 125MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者