Beispiel #1
0
int main()
{
	int i,n;
	while(scanf("%d",&n)!=EOF){
		init();
		for(i=1;i<=n;i++){
			multipy(i);
		}
		bprint();
	}
	return 0;
}
Beispiel #2
0
int main() {
	int cmd, x, y, z, w;
	Frac a, b, c;
	scanf("%d", &cmd);
	scanf("%d %d %d %d", &x, &y, &z, &w);
	a = normal(x, y), b = normal(z, w);
	if (cmd == 1) {
		c = add(a, b);
	} else if (cmd == 2) {
		c = subtract(a, b);
	} else if (cmd == 3) {
		c = multipy(a, b);
	} else if (cmd == 4) {
		c = divide(a, b);
	}
	printf("%lld / %lld\n", c.a, c.b);
	return 0;
}
Beispiel #3
0
int main()
{
	init();
	long num, i = 0, j = 0;
	scanf("%ld", &num);
	long tmat[4] = {1,1,1,1};
	num-=1;
	while (num) {
		long re = num % 2;
		if (re == 1) {
			multipy(tmat, mat[i]);
		}
		num /= 2;
		i++;
	}
	long f0 = 0, f1 = 1;
	long fn = ((f0 * tmat[0]) % MOD + (f1 * tmat[1]) % MOD ) % MOD;
	printf("%ld\n", fn);
	return 0;
}