#include <stdio.h>
#include <time.h>

unsigned int Now() {
	time_t timer;
	struct tm* ptm;

	timer = time(NULL);
	ptm = localtime(&timer);

	return ptm->tm_year * 365 + (ptm->tm_year - 1) / 4 + ptm->tm_yday + 2;
}

void main()
{
	unsigned long today, code1, code2, code3, tcode;
	char authcode[100];

	printf("Financial Engineer Authorization String Generator (by Fossil)\n");

	today = Now();
	code1 = (today - 2712) * 13 + 81193;
	code2 = (today + 90 - 2712) * 13 + 81193;
	code3 = 0;
	tcode = code2;
	while (tcode > 0) {
		code3 += tcode % 10;
		tcode = tcode / 10;
	}

	printf("\nAuthorization code : %luP0%lu%02u\n", code1, code2, code3);
	printf("\nNOTE: This code is valid *today* only !\n");
}