#include <stdlib.h>
#include <stdio.h>

//float lookup[33] = {0.000000, 0.031250, 0.062500, 0.093750, 0.125000, 0.156250, 0.187500, 0.218750, 0.250000, 0.281250, 0.312500, 0.343750, 0.375000, 0.406250, 0.437500, 0.468750, 0.500000,
//                    0.531250, 0.562500, 0.593750, 0.625000, 0.656250, 0.687500, 0.718750, 0.750000, 0.781250, 0.812500, 0.843750, 0.875000, 0.906250, 0.937500, 0.968750, 1.000000};


float lookup[257] = {0.000000, 0.003906, 0.007812, 0.011719, 0.015625, 0.019531, 0.023438, 0.027344, 0.031250, 0.035156, 0.039062, 0.042969, 0.046875, 0.050781, 0.054688, 0.058594, 0.062500, 0.066406, 0.070312, 0.074219, 0.078125, 0.082031, 0.085938, 0.089844, 0.093750, 0.097656, 0.101562, 0.105469, 0.109375, 0.113281, 0.117188, 0.121094, 0.125000, 0.128906, 0.132812, 0.136719, 0.140625, 0.144531, 0.148438, 0.152344, 0.156250, 0.160156, 0.164062, 0.167969, 0.171875, 0.175781, 0.179688, 0.183594, 0.187500, 0.191406, 0.195312, 0.199219, 0.203125, 0.207031, 0.210938, 0.214844, 0.218750, 0.222656, 0.226562, 0.230469, 0.234375, 0.238281, 0.242188, 0.246094, 0.250000, 0.253906, 0.257812, 0.261719, 0.265625, 0.269531, 0.273438, 0.277344, 0.281250, 0.285156, 0.289062, 0.292969, 0.296875, 0.300781, 0.304688, 0.308594, 0.312500, 0.316406, 0.320312, 0.324219, 0.328125, 0.332031, 0.335938, 0.339844, 0.343750, 0.347656, 0.351562, 0.355469, 0.359375, 0.363281, 0.367188, 0.371094, 0.375000, 0.378906, 0.382812, 0.386719, 0.390625, 0.394531, 0.398438, 0.402344, 0.406250, 0.410156, 0.414062, 0.417969, 0.421875, 0.425781, 0.429688, 0.433594, 0.437500, 0.441406, 0.445312, 0.449219, 0.453125, 0.457031, 0.460938, 0.464844, 0.468750, 0.472656, 0.476562, 0.480469, 0.484375, 0.488281, 0.492188, 0.496094, 0.500000, 0.503906, 0.507812, 0.511719, 0.515625, 0.519531, 0.523438, 0.527344, 0.531250, 0.535156, 0.539062, 0.542969, 0.546875, 0.550781, 0.554688, 0.558594, 0.562500, 0.566406, 0.570312, 0.574219, 0.578125, 0.582031, 0.585938, 0.589844, 0.593750, 0.597656, 0.601562, 0.605469, 0.609375, 0.613281, 0.617188, 0.621094, 0.625000, 0.628906, 0.632812, 0.636719, 0.640625, 0.644531, 0.648438, 0.652344, 0.656250, 0.660156, 0.664062, 0.667969, 0.671875, 0.675781, 0.679688, 0.683594, 0.687500, 0.691406, 0.695312, 0.699219, 0.703125, 0.707031, 0.710938, 0.714844, 0.718750, 0.722656, 0.726562, 0.730469, 0.734375, 0.738281, 0.742188, 0.746094, 0.750000, 0.753906, 0.757812, 0.761719, 0.765625, 0.769531, 0.773438, 0.777344, 0.781250, 0.785156, 0.789062, 0.792969, 0.796875, 0.800781, 0.804688, 0.808594, 0.812500, 0.816406, 0.820312, 0.824219, 0.828125, 0.832031, 0.835938, 0.839844, 0.843750, 0.847656, 0.851562, 0.855469, 0.859375, 0.863281, 0.867188, 0.871094, 0.875000, 0.878906, 0.882812, 0.886719, 0.890625, 0.894531, 0.898438, 0.902344, 0.906250, 0.910156, 0.914062, 0.917969, 0.921875, 0.925781, 0.929688, 0.933594, 0.937500, 0.941406, 0.945312, 0.949219, 0.953125, 0.957031, 0.960938, 0.964844, 0.968750, 0.972656, 0.976562, 0.980469, 0.984375, 0.988281, 0.992188, 0.996094, 1.000000};



const char *ztincrements[256] = {"000", "001", "002", "003", "005", "006", "007", "008", "010", "011", "012", "013", "015", "016", "017", "018", "020", "021", "022",
				"023", "025", "026", "027", "028", "030", "031", "032", "033", "035", "036", "037", "038", "040", "041", "042", "043", "045", "046",
				"047", "048", "050", "051", "052", "053", "055", "056", "057", "058", "060", "061", "062", "063", "065", "066", "067", "068", "070",
				"071", "072", "073", "075", "076", "077", "078", "080", "081", "082", "083", "085", "086", "087", "088", "090", "091", "092", "093",
				"095", "096", "097", "098", "100", "101", "102", "103", "105", "106", "107", "108", "110", "111", "112", "113", "115", "116", "117",
				"118", "120", "121", "122", "123", "125", "126", "127", "128", "130", "131", "132", "133", "135", "136", "137", "138", "140", "141",
				"142", "143", "145", "146", "147", "148", "150", "151", "152", "153", "155", "156", "157", "158", "160", "161", "162", "163", "165",
				"166", "167", "168", "170", "171", "172", "173", "175", "176", "177", "178", "180", "181", "182", "183", "185", "186", "187", "188",
				"190", "191", "192", "193", "195", "196", "197", "198", "200", "201", "202", "203", "205", "206", "207", "208", "210", "211", "212",
				"213", "215", "216", "217", "218", "220", "221", "222", "223", "225", "226", "227", "228", "230", "231", "232", "233", "235", "236",
				"237", "238", "240", "241", "242", "243", "245", "246", "247", "248", "250", "251", "252", "253", "255", "256", "257", "258", "260",
				"261", "262", "263", "265", "266", "267", "268", "270", "271", "272", "273", "275", "276", "277", "278", "280", "281", "282", "283",
				"285", "286", "287", "288", "290", "291", "292", "293", "295", "296", "297", "298", "300", "301", "302", "303", "305", "306", "307",
				"308", "310", "311", "312", "313", "315", "316", "317", "318"};

// DECIMAL to ZT increments

//0.00390625

int thirtyseconds[32] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
int eights[8] = {0,1,2,3,5,6,7,8};

#define INCREMENTS 319
//const float increment = 1/(INCREMENTS-1);

const float increment = 0.003144654;
//float lookup[INCREMENTS];

// = {0.000000, , 1.000000};
//0.00313479
//One-eighth of one thirty-second (1/32) of one point ($7.8125, rounded to the nearest cent per contract), including intermonth spreads.
//0.003144654

/*
void initialize(void){
	int num1 = 0;
	lookup[num1++] = 0.00;
	while(num1<INCREMENTS){
		lookup[num1] = increment*num1;
		//num1++;
		//printf("%d/318th %f\n", num1+1, lookup[num1]);
		num1++;
	}
	lookup[num1-1] = 1.000000;
}
*/


int main(int argc, char **argv){
	//float change = 0;
	int num1 = 0;
	int num2 = 0;
	float tmp = 0;
	float input = atof(argv[1]);
	int dig_a;
	int dig_b;
	int output;
	float input_orig = input;
	//x-(x/y)*y
	input -= (int)input/1;




	//for(num1=0; num1<32; num1++){
		//change = num1;
		//change /= 32;
		//printf("%d/32 %f\n", num1+1, lookup[num1]);
	//}
	//initialize();

	//tmp = input/0.00390625;
	//for(num1=0; num1<257; num1++){
		//printf("%f, ", tmp);
		//tmp+=0.00390625;
		
	//}

//	for(num1=0; num1<32; num1++){
//		for(num2=0; num2<8; num2++){
//			printf("%02d%01d, ", thirtyseconds[num1], eights[num2]);
//
//		}
//	}


	while(input>lookup[num1])
		num1++;
	if(input == 1)
		num1 = 1;
	//printf("%d/318th %f\n", num1-1, lookup[num1-1]);
	printf("%f = %s \n", input_orig, ztincrements[num1]);

	return 0;
}
