Language: C++

import java.lang.*;
import java.lang.Number.*;
import java.math.*;
import java.util.*;

class RealNumber{ // a/b
    public BigInteger a;
    public BigInteger b;
    public RealNumber(BigInteger aa, BigInteger bb){
	a = aa;
	b = bb;
    }
    public RealNumber(String sa, String sb){
	a = new BigInteger(sa);
	b = new BigInteger(sb);
    }
    public void add(RealNumber r){
	BigInteger G=b.gcd(r.b);
	BigInteger tmpb=b.multiply(r.b.divide(G));
	a=a.multiply(r.b.divide(G)).add(r.a.multiply(b.divide(G)));
	b=tmpb;
    }
    public BigDecimal toBigDecimal(int r){
	BigDecimal ret = new BigDecimal(a);
	ret = ret.divide(new BigDecimal(b),r,BigDecimal.ROUND_DOWN);
	return ret;
    }
    public void out(){
	System.out.println(a+" / " +b);
    }
}

class Main{
    public static void main(String  []s ){
	Scanner sc = new Scanner(System.in);
	RealNumber table[] = new RealNumber[10001];
	RealNumber R = new RealNumber(new BigInteger("1"),new BigInteger("1"));
	table[1]=R;
	for(int i = 2; i < 10001; ++i){
	    R.add( new RealNumber(Integer.toString(1),Integer.toString(i)) );
	    table[i]=R;
	}
	while(true){
	    int n,k,m,r;
	    BigDecimal ans=new BigDecimal(0);
	    n = sc.nextInt();
	    k = sc.nextInt();
	    m = sc.nextInt();
	    r = sc.nextInt();
	    if(n==0&&k==0&&m==0&&r==0)break;
	    BigDecimal bdn = new BigDecimal(n);
	    if(m == 0){
		ans = BigDecimal.ONE.divide(bdn,r+10,BigDecimal.ROUND_DOWN);
	    }else{
		ans = BigDecimal.ONE.divide(bdn,r+10,BigDecimal.ROUND_DOWN);
		BigDecimal bdtmp = new BigDecimal(table[n-1].a);
		bdtmp = bdtmp.divide( new BigDecimal(table[n-1].b), r+10, BigDecimal.ROUND_DOWN);
		bdtmp = bdtmp.multiply(ans);
		ans = ans.add(bdtmp);
	    }
	    System.out.println( ans.divide(BigDecimal.ONE,r,BigDecimal.ROUND_DOWN) );
	}
    }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.lang.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.lang.Number.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.math.*;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.*;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:11: error: expected ':' before 'BigInteger'
    7 |     public BigInteger a;
      |           ^~~~~~~~~~~
      |           :
a.cc:7:12: error: 'BigInteger' does not name a type
    7 |     public BigInteger a;
      |            ^~~~~~~~~~
a.cc:8:11: error: expected ':' before 'BigInteger'
    8 |     public BigInteger b;
      |           ^~~~~~~~~~~
      |           :
a.cc:8:12: error: 'BigInteger' does not name a type
    8 |     public BigInteger b;
      |            ^~~~~~~~~~
a.cc:9:11: error: expected ':' before 'RealNumber'
    9 |     public RealNumber(BigInteger aa, BigInteger bb){
      |           ^~~~~~~~~~~
      |           :
a.cc:9:33: error: expected ')' before 'aa'
    9 |     public RealNumber(BigInteger aa, BigInteger bb){
      |                      ~          ^~~
      |                                 )
a.cc:13:11: error: expected ':' before 'RealNumber'
   13 |     public RealNumber(String sa, String sb){
      |           ^~~~~~~~~~~
      |           :
a.cc:13:29: error: expected ')' before 'sa'
   13 |     public RealNumber(String sa, String sb){
      |                      ~      ^~~
      |                             )
a.cc:17:11: error: expected ':' before 'void'
   17 |     public void add(RealNumber r){
      |           ^~~~~
      |           :
a.cc:23:11: error: expected ':' before 'BigDecimal'
   23 |     public BigDecimal toBigDecimal(int r){
      |           ^~~~~~~~~~~
      |           :
a.cc:23:12: error: 'BigDecimal' does not name a type
   23 |     public BigDecimal toBigDecimal(int r){
      |            ^~~~~~~~~~
a.cc:28:11: error: expected ':' before 'void'
   28 |     public void out(){
      |           ^~~~~
      |           :
a.cc:31:2: error: expected ';' after class definition
   31 | }
      |  ^
      |  ;
a.cc: In member function 'void RealNumber::add(RealNumber)':
a.cc:18:9: error: 'BigInteger' was not declared in this scope
   18 |         BigInteger G=b.gcd(r.b);
      |         ^~~~~~~~~~
a.cc:19:20: error: expected ';' before 'tmpb'
   19 |         BigInteger tmpb=b.multiply(r.b.divide(G));
      |                    ^~~~
a.cc:20:9: error: 'a' was not declared in this scope
   20 |         a=a.multiply(r.b.divide(G)).add(r.a.multiply(b.divide(G)));
      |         ^
a.cc:20:24: error: 'class RealNumber' has no member named 'b'
   20 |         a=a.multiply(r.b.divide(G)).add(r.a.multiply(b.divide(G)));
      |                        ^
a.cc:20:33: error: 'G' was not declared in this scope
   20 |         a=a.multiply(r.b.divide(G)).add(r.a.multiply(b.divide(G)));
      |                                 ^
a.cc:20:43: error: 'class RealNumber' has no member named 'a'
   20 |         a=a.multiply(r.b.divide(G)).add(r.a.multiply(b.divide(G)));
      |                                           ^
a.cc:20:54: error: 'b' was not declared in this scope
   20 |         a=a.multiply(r.b.divide(G)).add(r.a.multiply(b.divide(G)));
      |                                                      ^
a.cc:21:11: error: 'tmpb' was not declared in this scope
   21 |         b=tmpb;
      |           ^~~~
a.cc: In member function 'void RealNumber::out()':
a.cc:29:9: error: 'System' was not declared in this scope
   29 |         System.out.println(a+" / " +b);
      |         ^~~~~~
a.cc:29:28: error: 'a' was not declared in this scope
   29 |         System.out.println(a+" / " +b);
      |                            ^
a.cc:29:37: error: 'b' was not declared in this scope
   29 |         System.out.println(a+" / " +b);
      |                                     ^
a.cc: At global scope:
a.cc:34:11: error: expected ':' before 'static'
   34 |     public static void main(String  []s ){
      |           ^~~~~~~
      |           :
a.cc:34:29: error: 'String' has not been declared
   34 |     public static void main(String  []s ){
      |                             ^~~~~~
a.cc:34:39: error: expected ',' or '...' before 's'
   34 |     public static void main(String  []s ){
      |                                       ^
a.cc:64:2: error: expected ';' after class definition
   64 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:35:9: error: 'Scanner' was not declared in this scope
   35 |         Scanner sc = new Scanner(System.in);
      |         ^~~~~~~
a.cc:36:30: error: initializer fails to determine size of 'table'
   36 |         RealNumber table[] = new RealNumber[10001];
      |                              ^~~~~~~~~~~~~~~~~~~~~
a.cc:36:30: error: array must be initialized with a brace-enclosed initializer
a.cc:37:43: error: expected type-specifier before 'BigInteger'
   37 |         RealNumber R = new RealNumber(new BigInteger("1"),new BigInteger("1"));
      |                                           ^~~~~~~~~~
a.cc:37:63: error: expected type-specifier before 'BigInteger'
   37 |         RealNumber R = new RealNumber(new BigInteger("1"),new BigInteger("1"));
      |                                                               ^~~~~~~~~~
a.cc:37:78: error: new initializer expression list treated as compound expression [-fpermissive]
   37 |         RealNumber R = new RealNumber(new BigInteger("1"),new BigInteger("1"));
      |                                                                              ^
a.cc:40:35: error: 'Integer' was not declared in this scope
   40 |             R.add( new RealNumber(Integer.toString(1),Integer.toString(i)) );
      |                                   ^~~~~~~
a.cc:40:74: error: new initializer expression list treated as compound expression [-fpermissive]
   40 |             R.add( new RealNumber(Integer.toString(1),Integer.toString(i)) );
      |                                                                          ^
a.cc:45:13: error: 'BigDecimal' was not declared in this scope
   45 |             BigDecimal ans=new BigDecimal(0);
      |             ^~~~~~~~~~
a.cc:46:17: error: 'sc' was not declared in this scope
   46 |             n = sc.nextInt();
      |                 ^~
a.cc:51:24: error: expected ';' before 'bdn'
   51 |             BigDecimal bdn = new BigDecimal(n);
      |                        ^~~
a.cc:53:17: error: 'ans' was not declared in this scope
   53 |                 ans = BigDecimal.ONE.divide(bdn,r+10,BigDecimal.ROUND_DOWN);
      |                 ^~~
a.cc:53:45: error: 'bdn' was not declared in this scope
   53 |                 ans = BigDecimal.ONE.divide(bdn,r+10,BigDecimal.ROUND_DOWN);
      |                                             ^~~
a.cc:55:17: error: 'ans' was not declared in this scope
   55 |                 ans = BigDecimal.ONE.divide(bdn,r+10,BigDecimal.ROUND_DOWN);
      |                 ^~~
a.cc:55:45: error: 'bdn' was not declared in this scope
   55 |                 ans = BigDecimal.ONE.divide(bdn,r+10,BigDecimal.ROUND_DOWN);
      |                                             ^~~
a.cc:56:28: error: expected ';' before 'bdtmp'
   56 |                 BigDecimal bdtmp = new BigDecimal(table[n-1].a);
      |                            ^~~~~
a.cc:57:17: error: 'bdtmp' was not declared in this scope
   57 |                 bdtmp = bdtmp.divide( new BigDecimal(table[n-1].b), r+10, BigDecimal.ROUND_DOWN);
      |                 ^~~~~
a.cc:57:43: error: expected type-specifier before 'BigDecimal'
   57 |                 bdtmp = bdtmp.divide( new BigDecimal(table[n-1].b), r+10, BigDecimal.ROUND_DOWN);
      |                                           ^~~~~~~~~~
a.cc:61:13: error: 'System' was not declared in this scope
   61 |             System.out.println( ans.divide(BigDecimal.ONE,r,BigDecimal.ROUND_DOWN) );
      |             ^~~~~~
a.cc:61:33: error: 'ans' was not declared in this scope
   61 |             System.out.println( ans.divide(BigDecimal.ONE,r,BigDecimal.ROUND_DOWN) );
      |                                 ^~~