-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1391C.cpp
More file actions
170 lines (149 loc) · 3.63 KB
/
Copy path1391C.cpp
File metadata and controls
170 lines (149 loc) · 3.63 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#include <bits/stdc++.h>
using namespace std;
char nl = '\n';
char sp = ' ';
using ll = long long;
using vb = vector<bool>;
using vl = vector<ll>;
using vvb = vector<vb>;
using vvl = vector<vl>;
using sl = unordered_set<ll>;
using tsl = set<ll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using mll = map<ll, ll>;
using umll = unordered_map<ll, ll>;
using maxheap = priority_queue<ll>; // maxheap
using minheap = priority_queue<ll, vl, greater<ll>>; // minheap
using pqm = priority_queue<pll>;
#define tp3(T) tuple<T, T, T>
#define tp4(T) tuple<T, T, T, T>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sort_and_unique(a) \
sort(all(a)); \
(a).resize(unique(all(a)) - (a).begin())
#define fo(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define foo(i, n) for (int(i) = 1; (i) <= (n); (i)++)
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define pw(x) (1LL << (x))
#define setbits(x) __builtin_popcountll(x)
#define debug(x) cout << #x << ": " << x << endl
#define debugArr(arr) \
{ \
cout << #arr << " : "; \
for (const auto &_element : arr) \
{ \
cout << _element << ' '; \
} \
cout << endl; \
}
void yesno(bool a)
{
cout << (a ? "Yes\n" : "No\n");
}
template <typename L, typename R>
ostream &operator<<(ostream &out, const pair<L, R> &p)
{
out << '(' << p.first << ',' << p.second << ')';
return out;
}
template <typename T1, typename T2, typename T3>
ostream &operator<<(ostream &out, const tuple<T1, T2, T3> &tp)
{
auto &[t1, t2, t3] = tp;
out << '(' << t1 << ',' << t2 << ',' << t3 << ')';
return out;
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v)
{
for (auto &i : v)
out << i << ' ';
out << nl;
return out;
}
template <typename T, size_t N>
ostream &operator<<(ostream &out, const array<T, N> &arr)
{
for (const auto &element : arr)
out << element << ' ';
out << nl;
return out;
}
template <typename T>
ostream &operator<<(ostream &out, const set<T> &v)
{
for (auto &i : v)
out << i << ' ';
out << nl;
return out;
}
template <typename T>
ostream &operator<<(ostream &out, const unordered_set<T> &v)
{
for (auto &i : v)
out << i << ' ';
out << nl;
return out;
}
template <typename K, typename V>
ostream &operator<<(ostream &out, const map<K, V> &m)
{
out << '[';
for (auto &[k, v] : m)
{
out << k << ':' << v << sp;
}
out << "]\n";
return out;
}
template <typename K, typename V>
ostream &operator<<(ostream &out, const unordered_map<K, V> &m)
{
out << '[';
for (auto &[k, v] : m)
{
out << k << ':' << v << sp;
}
out << "]\n";
return out;
}
template<typename T>
istream& operator >>(istream& istream, vector<T>& v) {
for(auto& element : v) {
cin >> element;
}
return istream;
}
const ll Mod = 998244353;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
void solve()
{
ll n;
cin>>n;
ll ans = 1, p = 1;
for(ll i=1;i<=n;i++) {
ans = (ans*i)%mod;
}
for(ll i=1;i<n;i++) {
p = (p*2)%mod;
}
cout<<(ans-p+mod)%mod<<endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
//freopen("moobuzz.in", "r", stdin);
//freopen("moobuzz.out", "w", stdout);
solve();
return 0;
}