Commit 42937c50 authored by uiekn's avatar uiekn Committed by uwdkn

Syntax test cases from group 3

parent 029ac0e9
class ident {
public ident ident () {
ident[3] ident;
}
}
\ No newline at end of file
class ident {
public ident ident () {
ident[];
}
}
\ No newline at end of file
class ManyPostfixOps {
public static void main(String[] args) {
ident[ident]();
}
}
/**
* Implementation of the sieve of Eratosthenes.
*
* Computes all prime numbers in the interval [2,n], where n is read from stdin.
* Note that System.in.read() returns the ASCII value of the character read!
*/
class Eratosthenes {
public int[] result;
public int count;
public void sieve(int max) {
boolean[] sieve = new boolean[max];
count = 0;
/* Initialize array. */
{
sieve[0] = false;
sieve[1] = false;
int i = 2;
while (i < max) {
sieve[i] = true;
i = i + 1;
}
}
/* Sieve of Eratosthenes algorithm. */
{
int prime = 2;
while (prime < max) {
if (sieve[prime]) {
count = count + 1;
/* Deliberately unoptimized (strength reduction is possible). */
int mult = prime;
while (prime * mult < max) {
sieve[prime * mult] = false;
mult = mult + 1;
}
}
prime = prime + 1;
}
}
result = new int[count];
{
int i = 0;
int j = 0;
while (i < max) {
if (sieve[i]) {
result[j] = i;
j = j + 1;
}
i = i + 1;
}
}
}
public static void main(String[] args) throws Exception {
Eratosthenes e = new Eratosthenes();
int num = System.in.read();
e.sieve(num);
{
int i = 0;
System.out.println(e.count);
while (i < e.count) {
System.out.println(e.result[i]);
i = i + 1;
}
}
}
}
class FloatArithmetic {
public int _2p8;
public int _2p11;
public int _2p16;
public int _2p23;
public int _2p24;
public int _int_min;
public int _f1_5;
public int _fNaN;
public int _seemlinglyArbitraryConstant;
public int _exponentBias;
public void init() {
_2p8 = 256;
_2p11 = 2048;
_2p16 = 65536;
_2p23 = 8388608;
_2p24 = 16777216;
_int_min = -2147483648;
_f1_5 = 1069547520;
_fNaN = -1;
_seemlinglyArbitraryConstant = 1597463007;
_exponentBias = 127;
}
public int buildFloat(int sign, int exponent, int mantissa) {
int result = exponent * _2p23 + mantissa;
if (sign == 1) {
result = negate(result);
}
return result;
}
public int negate(int x) {
return _int_min + x;
}
public int sign(int x) {
if (x >= 0) {
return 0;
} else {
return 1;
}
}
public int exponent(int x) {
if (x < 0) {
x = negate(x);
}
return x / _2p23 % _2p8;
}
public int mantissa(int x) {
if (x < 0) {
x = negate(x);
}
return x % _2p23;
}
public int div2(int x) {
int mantissa = mantissa(x);
int exponent = exponent(x);
if (exponent == 0) {
return 0;
} else {
return buildFloat(sign(x), exponent(x) - 1, mantissa(x));
}
}
public int add(int x, int y) {
int xm = mantissa(x);
int xe = exponent(x);
int xs = sign(x);
int ym = mantissa(y);
int ye = exponent(y);
int ys = sign(y);
int exponentDiff;
int exponent;
int mantissa;
int sign;
int lm;
int sm;
if (xe > ye) {
exponentDiff = xe - ye;
exponent = xe;
sign = xs;
lm = xm;
sm = ym;
} else {
exponentDiff = ye - xe;
exponent = ye;
lm = ym;
sm = xm;
if (xe < ye || xm < ym) {
sign = ys;
} else {
sign = xs;
}
}
lm = lm + _2p23;
sm = sm + _2p23;
while (exponentDiff > 0) {
sm = sm / 2;
exponentDiff = exponentDiff - 1;
}
if (xs == ys) {
mantissa = lm + sm;
} else {
mantissa = lm - sm;
}
if (mantissa / _2p24 == 1) {
mantissa = mantissa / 2;
mantissa = mantissa % _2p23;
exponent = exponent + 1;
} else {
mantissa = mantissa % _2p23;
}
return buildFloat(sign, exponent, mantissa);
}
public int square(int x) {
return mult(x, x);
}
public int mult(int x, int y) {
int xm = mantissa(x);
int xe = exponent(x);
int xs = sign(x);
int ym = mantissa(y);
int ye = exponent(y);
int ys = sign(y);
xm = xm + _2p23;
ym = ym + _2p23;
int xm_lo = xm % _2p11;
int ym_lo = ym % _2p11;
int xm_hi = xm / _2p11;
int ym_hi = ym / _2p11;
int mantissa_lo = xm * ym;
int mantissa_hi = xm_hi * ym_hi
+ xm_hi * ym_lo / _2p11
+ xm_lo * ym_hi / _2p11
+ (xm_lo * ym_hi + xm_lo * ym_hi + mantissa_lo / _2p11) / _2p11;
int exponent = xe + ye - _exponentBias;
int mantissa = mantissa_hi / 2;
if (mantissa / _2p24 == 1) {
mantissa = mantissa / 2;
mantissa = mantissa % _2p23;
exponent = exponent + 1;
} else {
mantissa = mantissa % _2p23;
}
return buildFloat((xs + ys) % 2, exponent, mantissa);
}
public int invSqrt(int num) {
if (num <= 0) {
return _fNaN;
}
int x2 = div2(num);
int y = _seemlinglyArbitraryConstant - num / 2;
y = mult(y, add(_f1_5, negate(mult(x2, square(y)))));
return y;
}
public static void main(String[] args) {
ComplexArithmetic ca = new ComplexArithmetic();
ca.init();
/*System.out.println(Float.intBitsToFloat(ca.add(1036831949, 1069547520))); // 0.1 + 1.5
System.out.println(Float.intBitsToFloat(ca.add(1065353216, 1069547520))); // 1.0 + 1.5
System.out.println(Float.intBitsToFloat(ca.add(1069547520, 1069547520))); // 1.5 + 1.5
System.out.println(Float.intBitsToFloat(ca.add(1073741824, 1069547520))); // 2.0 + 1.5
System.out.println();
System.out.println(Float.intBitsToFloat(ca.mult(1036831949, 1069547520))); // 0.1 * 1.5
System.out.println(Float.intBitsToFloat(ca.mult(1065353216, 1069547520))); // 1.0 * 1.5
System.out.println(Float.intBitsToFloat(ca.mult(1069547520, 1069547520))); // 1.5 * 1.5
System.out.println(Float.intBitsToFloat(ca.mult(1073741824, 1069547520))); // 2.0 * 1.5
System.out.println();
System.out.println(Float.intBitsToFloat(ca.invSqrt(1036831949))); // 1 / sqrt(0.1)
System.out.println(Float.intBitsToFloat(ca.invSqrt(1065353216))); // 1 / sqrt(1.0)
System.out.println(Float.intBitsToFloat(ca.invSqrt(1069547520))); // 1 / sqrt(1.5)
System.out.println(Float.intBitsToFloat(ca.invSqrt(1073741824))); // 1 / sqrt(2.0)*/
}
}
class ManyPostfixOps {
public static void main(String[] args) {
ident(ident.ident[ident].indent(ident[ident(ident)[ident]], ident))[0][0][0][0][0];
}
}
class NonPublicField {
int field;
}
class ident {
public ident ident () {
new int[][][];
}
}
\ No newline at end of file
class ident {
public int [][][][][][] ident;
public void ident;
public int ident;
public boolean ident;
public ident ident;
public static void main(String[] args) {}
public static void main(String[] args) throws ident {}
public int[] method () {}
public ident method (int param) {}
public boolean method (boolean param1, void param2) {}
public int method () throws ident {}
public void method (ident param) throws ident {}
public ident method (int[] param1, boolean[][] param2) throws ident {
;;;;;
boolean ident = 42;
new int[3][4];
new void[42][][];
return true;
}
}
\ No newline at end of file
class ident1 {}
class ident2 {}
class ident3 {}
\ No newline at end of file
class ident {
public ident ident () {{}{{}}}
}
\ No newline at end of file
class ident {
public boolean ident = false;
}
\ No newline at end of file
class name {
public void method() {
(!---!-!!!!!-42 && x + 5 != y || 42 == 13 * 4 = x / 42 % z - 576 <= 18 > 11 + 3--4).method2(3+4, false, null);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment