package com.menzus.gcj._2012.qualification.c;

import com.menzus.gcj.common.InputBlockParser;
import com.menzus.gcj.common.OutputProducer;
import com.menzus.gcj.common.impl.AbstractProcessorFactory;

public class CProcessorFactory extends AbstractProcessorFactory<CInput, COutputEntry> {
    public CProcessorFactory(String inputFileName) {
	super(inputFileName);
    }

    @Override
    protected InputBlockParser<CInput> createInputBlockParser() {
	return new CInputBlockParser();
    }

    @Override
    protected OutputProducer<CInput, COutputEntry> createOutputProducer() {
	return new COutputProducer();
    }
}

package MyAllgoritmicLib;

public class BinaryPower {
	public static int binpow (int a, int n)
	{
		int r = 1;
		while (n > 0)
			if (n % 2 == 0)
			{
				a *= a;
				n /= 2;
			}
			else
			{
				r *= a;
				--n;
			}
		return r;
	}
	
	public static long binpow (long a, int n)
	{
		long r = 1;
		while (n > 0)
			if (n % 2 == 0)
			{
				a *= a;
				n /= 2;
			}
			else
			{
				r *= a;
				--n;
			}
		return r;
	}
	
	public static double binpow (double a, int n)
	{
		double r = 1;
		while (n > 0)
			if (n % 2 == 0)
			{
				a *= a;
				n /= 2;
			}
			else
			{
				r *= a;
				--n;
			}
		return r;
	}
}
