File tree 4 files changed +132
-0
lines changed
4 files changed +132
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ using namespace std ;
3
+
4
+ int main () {
5
+ int a, b, c;
6
+
7
+ cin >> a >> b >> c;
8
+
9
+ cout << 21 - (a + b + c) << endl;
10
+ }
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ #include < string>
3
+ using namespace std ;
4
+
5
+ int main () {
6
+ string s;
7
+ cin >> s;
8
+ for (int i = s.size () - 1 ; i >= 0 ; i--)
9
+ {
10
+ if (s[i] == ' 9' ) {
11
+ cout << 6 ;
12
+ }
13
+ else if (s[i] == ' 6' )
14
+ {
15
+ cout << 9 ;
16
+ }
17
+ else
18
+ {
19
+ cout << s[i];
20
+ }
21
+ }
22
+ cout << endl;
23
+ }
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ using namespace std ;
3
+
4
+ long long a[100000 ], b[100000 ], c[100000 ];
5
+ long long acnt[100001 ], bcnt[100000 ];
6
+
7
+ int main () {
8
+ int n;
9
+ cin >> n;
10
+ for (int i = 0 ; i < n; i++)
11
+ {
12
+ cin >> a[i];
13
+ a[i]--;
14
+ acnt[a[i]]++;
15
+ }
16
+ for (int i = 0 ; i < n; i++)
17
+ {
18
+ cin >> b[i];
19
+ b[i]--;
20
+ }
21
+ for (int i = 0 ; i < n; i++)
22
+ {
23
+ cin >> c[i];
24
+ c[i]--;
25
+ bcnt[b[c[i]]]++;
26
+ }
27
+
28
+ long long result = 0 ;
29
+ for (int i = 0 ; i < n; i++)
30
+ {
31
+ result += (acnt[i] * bcnt[i]);
32
+ }
33
+
34
+ cout << result << endl;
35
+ }
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+ #include < string>
3
+ using namespace std ;
4
+
5
+ long long C[61 ][61 ];
6
+
7
+ // Returns value of Binomial Coefficient C(n, k)
8
+ long long binomialCoeff (int n, int k)
9
+ {
10
+ int i, j;
11
+
12
+ // Caculate value of Binomial Coefficient
13
+ // in bottom up manner
14
+ for (i = 0 ; i <= n; i++) {
15
+ for (j = 0 ; j <= min (i, k); j++) {
16
+ // Base Cases
17
+ if (j == 0 || j == i)
18
+ C[i][j] = 1 ;
19
+
20
+ // Calculate value using previously
21
+ // stored values
22
+ else
23
+ C[i][j] = C[i - 1 ][j - 1 ] + C[i - 1 ][j];
24
+ }
25
+ }
26
+
27
+ return C[n][k];
28
+ }
29
+
30
+ string go (int a, int b, long long k) {
31
+ if (k <= 0 || a <= 0 || b <= 0 )
32
+ {
33
+ string ret = " " ;
34
+
35
+ while (a--)
36
+ {
37
+ ret += ' a' ;
38
+ }
39
+ while (b--)
40
+ {
41
+ ret += ' b' ;
42
+ }
43
+
44
+ return ret;
45
+ }
46
+
47
+ // a
48
+ long long c = binomialCoeff (a + b - 1 , a - 1 );
49
+ if (k <= c)
50
+ {
51
+ return ' a' + go (a - 1 , b, k);
52
+ }
53
+ else
54
+ {
55
+ return ' b' + go (a, b - 1 , k - c);
56
+ }
57
+ }
58
+
59
+ int main () {
60
+ long long a, b, k;
61
+ cin >> a >> b >> k;
62
+
63
+ cout << go (a, b, k) << endl;
64
+ }
You can’t perform that action at this time.
0 commit comments