about summary refs log tree commit diff
path: root/codechef/redone.c
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-05-14 11:55:28 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-05-14 11:55:28 +0700
commit267b2db7addc95c5eebb8bfb9ceeb7b953d85732 (patch)
tree8a9669a99fccaf520b3cb690143e539c58a92ca5 /codechef/redone.c
parent887c286cc8228e13f85b587ab92b37e920161eb9 (diff)
downloadcp-267b2db7addc95c5eebb8bfb9ceeb7b953d85732.tar.gz
I has always believed that I'm good at solving math problems
Turns out I has been wrong all the time. And I'm not alone.
Diffstat (limited to 'codechef/redone.c')
-rw-r--r--codechef/redone.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/codechef/redone.c b/codechef/redone.c
new file mode 100644
index 0000000..b73fe0e
--- /dev/null
+++ b/codechef/redone.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main()
+{
+	long long *result = malloc(sizeof(long) * 1000001);
+	result[0] = 1;
+	for (long i = 1; i < 1000002; ++i)
+		result[i] = result[i - 1] * (i + 1) % 1000000007;
+	
+	long t, n;
+	scanf("%ld", &t);
+	while (t--) {
+		scanf("%ld", &n);
+		printf("%ld\n", (result[n] - 1) % 1000000007);
+	}
+	
+	return 0;
+}