Language: Java

#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;
int a,n,tp,tq;
 
void rec(int p,int q,int an,int &cnt,int k,int total)
{
  if(total > a)return;
  if(an > n)return;
  if(p*tq > tp*q)return;
  if(((n-an)*q+k*p)*tq < tp*k*q)return;
  if(p == tp && q == tq)
    {
      cnt++;
      return;
    }
 
  for(int i=k;q*i<=a;i++)
    {
      int A = p*i+q,B = q*i;
      if(total*i > a)continue;
      int gcd1 = __gcd(A,B);
      A /= gcd1;
      B /= gcd1; 
      rec(A,B,an+1,cnt,i,total*i);
    }
}
 
int main()
{
 
  while(1)
    {
      scanf("%d %d %d %d",&tp,&tq,&a,&n);
      if(!(tp|tq|a|n))break;
      int gcd1 = __gcd(tp,tq);
      tp /= gcd1;
      tq /= gcd1;
      int theNumber = 0;
      for(int i=1;i<=a;i++)
    {
      if(i > a)continue;
      rec(1,i,1,theNumber,i,i);
    }
      printf("%d\n",theNumber);
    }
  return 0;
}



Compiler output:
Main.java:1: error: illegal character: '#'
#include<iostream>
^
Main.java:2: error: illegal character: '#'
#include<algorithm>
^
Main.java:3: error: illegal character: '#'
#include<vector>
^
Main.java:4: error: illegal character: '#'
#include<cstdio>
^
Main.java:6: error: class, interface, enum, or record expected
int a,n,tp,tq;
^
Main.java:8: error: unnamed classes are a preview feature and are disabled by default.
void rec(int p,int q,int an,int &cnt,int k,int total)
^
  (use --enable-preview to enable unnamed classes)
Main.java:8: error: <identifier> expected
void rec(int p,int q,int an,int &cnt,int k,int total)
                               ^
Main.java:8: error: class, interface, enum, or record expected
void rec(int p,int q,int an,int &cnt,int k,int total)
                                     ^
Main.java:11: error: class, interface, enum, or record expected
  if(an > n)return;
  ^
Main.java:12: error: class, interface, enum, or record expected
  if(p*tq > tp*q)return;
  ^
Main.java:13: error: class, interface, enum, or record expected
  if(((n-an)*q+k*p)*tq < tp*k*q)return;
  ^
Main.java:14: error: class, interface, enum, or record expected
  if(p == tp && q == tq)
  ^
Main.java:17: error: class, interface, enum, or record expected
      return;
      ^
Main.java:18: error: class, interface, enum, or record expected
    }
    ^
Main.java:20: error: class, interface, enum, or record expected
  for(int i=k;q*i<=a;i++)
              ^
Main.java:20: error: class, interface, enum, or record expected
  for(int i=k;q*i<=a;i++)
                     ^
Main.java:23: error: class, interface, enum, or record expected
      if(total*i > a)continue;
      ^
Main.java:25: error: class, interface, enum, or record expected
      A /= gcd1;
      ^
Main.java:26: error: class, interface, enum, or record expected
      B /= gcd1; 
      ^
Main.java:27: error: class, interface, enum, or record expected
      rec(A,B,an+1,cnt,i,total*i);
      ^
Main.java:28: error: class, interface, enum, or record expected
    }
    ^
Main.java:37: error: class, interface, enum, or record expected
      if(!(tp|tq|a|n))break;
      ^
Main.java:39: error: class, interface, enum, or record expected
      tp /= gcd1;
      ^
Main.java:40: error: class, interface, enum, or record expected
      tq /= gcd1;
      ^
Main.java:42: error: class, interface, enum, or record expected
      for(int i=1;i<=a;i++)
      ^
Main.java:42: error: class, interface, enum, or record expected
      for(int i=1;i<=a;i++)
                  ^
Main.java:42: error: class, interface, enum, or record expected
      for(int i=1;i<=a;i++)
                       ^
Main.java:45: error: class, interface, enum, or record expected
      rec(1,i,1,theNumber,i,i);
      ^
Main.java:46: error: class, interface, enum, or record expected
    }
    ^
Main.java:48: error: class, interface, enum, or record expected
    }
    ^
Main.java:50: error: class, interface, enum, or record expected
}
^
31 errors