File tree Expand file tree Collapse file tree 3 files changed +94
-0
lines changed Expand file tree Collapse file tree 3 files changed +94
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+ using ll = int64_t ;
5
+ using ff = long double ;
6
+
7
+ int main () {
8
+ ios_base::sync_with_stdio (false );
9
+ cin.tie (0 ); cout.tie (0 );
10
+
11
+ int A, B;
12
+ string op;
13
+
14
+ cin >> A >> op >> B;
15
+
16
+ int ans = 0 ;
17
+ if (op == " +" ) {
18
+ ans = A + B;
19
+ } else if (op == " -" ) {
20
+ ans = A - B;
21
+ } else throw ;
22
+ cout << ans << endl;
23
+
24
+ return 0 ;
25
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+ using ll = int64_t ;
5
+ using ff = long double ;
6
+
7
+ int main () {
8
+ ios_base::sync_with_stdio (false );
9
+ cin.tie (0 ); cout.tie (0 );
10
+
11
+ int N, M;
12
+ vector<int > T;
13
+
14
+ cin >> N;
15
+ T.assign (N, 0 );
16
+ for (auto &t : T) cin >> t;
17
+ cin >> M;
18
+ for (int i = 0 ; i < M; ++i) {
19
+ int p, x;
20
+ cin >> p >> x;
21
+ --p;
22
+
23
+ int ans = 0 ;
24
+ for (int j = 0 ; j < N; ++j) {
25
+ if (j == p) ans += x;
26
+ else ans += T[j];
27
+ }
28
+ cout << ans << endl;
29
+ }
30
+
31
+ return 0 ;
32
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+ using ll = int64_t ;
5
+ using ff = long double ;
6
+
7
+ ll const MOD = 1e9 + 7 ;
8
+ int N;
9
+ vector<int > A;
10
+
11
+ ll solve () {
12
+ sort (A.begin (), A.end ());
13
+ if (N % 2 == 0 && A[0 ] == 0 ) return 0 ;
14
+ if (N % 2 == 1 && A[0 ] != 0 ) return 0 ;
15
+ for (int i = N % 2 ; i < N; i += 2 ) {
16
+ if (i > 0 && A[i] == A[i-1 ]) return 0 ;
17
+ if (A[i] != A[i+1 ]) return 0 ;
18
+ }
19
+ int M = N / 2 ;
20
+ ll ans = 1 ;
21
+ for (int i = 0 ; i < M; ++i) {
22
+ ans = (ans * 2 ) % MOD;
23
+ }
24
+ return ans;
25
+ }
26
+
27
+ int main () {
28
+ ios_base::sync_with_stdio (false );
29
+ cin.tie (0 ); cout.tie (0 );
30
+
31
+ cin >> N;
32
+ A.assign (N, 0 );
33
+ for (auto &a : A) cin >> a;
34
+ cout << solve () << endl;
35
+
36
+ return 0 ;
37
+ }
You can’t perform that action at this time.
0 commit comments