-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path663C.cpp
More file actions
38 lines (38 loc) · 728 Bytes
/
663C.cpp
File metadata and controls
38 lines (38 loc) · 728 Bytes
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
32
33
34
35
36
37
38
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000000+7;
#define ll long long int
ll bigmod(ll a, ll b){
if(a==0)return a;
ll product = 1ll;
while (b >= 1)
{
if(b&1){
product*=a;
product%=mod;
b--;
}
a*=a;
a%=mod;
b/=2;
}
return product;
}
int main()
{
long long int arr[1000000+1];
long long int mod = 1000000000+7;
arr[0] = 1ll;
for (int i = 1; i < 1000000+1; i++)
{
arr[i]= arr[i-1]*(i*1ll);
arr[i]%=mod;
}
ll n;
scanf("%lld", &n);
long long int d = bigmod(2,n-1);
arr[n] -= d;
arr[n] += mod;
arr[n] %= mod;
printf("%lld\n",arr[n]);
}