File tree Expand file tree Collapse file tree 6 files changed +240
-0
lines changed Expand file tree Collapse file tree 6 files changed +240
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ author: Ali
3
+ Email: AliGhanbariCs@gmail.com
4
+ GitHub: https://github.com/AliBinary
5
+ created: 28.01.2024 14:49:02
6
+ */
7
+
8
+ #include < bits/stdc++.h>
9
+ using namespace std ;
10
+
11
+ int main ()
12
+ {
13
+ int t;
14
+ cin >> t;
15
+ while (t--)
16
+ {
17
+ long long a, b;
18
+ cin >> a >> b;
19
+ long long ans = abs ((ceil (a * 1 . / b) * b) - a);
20
+ cout << ans << endl;
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ author: Ali
3
+ Email: AliGhanbariCs@gmail.com
4
+ GitHub: https://github.com/AliBinary
5
+ created: 28.01.2024 19:24:14
6
+ */
7
+
8
+ #include < iostream>
9
+ using namespace std ;
10
+
11
+ int main ()
12
+ {
13
+ int n, m;
14
+ cin >> n >> m;
15
+ int a[n];
16
+ for (int i = 0 ; i < n; i++)
17
+ {
18
+ cin >> a[i];
19
+ }
20
+ int last;
21
+ while (1 )
22
+ {
23
+ bool flag = true ;
24
+ for (int i = 0 ; i < n; i++)
25
+ {
26
+ if (a[i] == 0 )
27
+ continue ;
28
+ else if (a[i] <= m)
29
+ {
30
+ a[i] = 0 ;
31
+ last = i;
32
+ flag = false ;
33
+ }
34
+ else
35
+ {
36
+ a[i] -= m;
37
+ last = i;
38
+ flag = false ;
39
+ }
40
+ }
41
+ if (flag)
42
+ break ;
43
+ }
44
+ cout << last + 1 ;
45
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ author: Ali
3
+ Email: AliGhanbariCs@gmail.com
4
+ GitHub: https://github.com/AliBinary
5
+ created: 28.01.2024 19:01:38
6
+ */
7
+
8
+ #include < bits/stdc++.h>
9
+ using namespace std ;
10
+
11
+ struct laptop
12
+ {
13
+ int x;
14
+ int y;
15
+ };
16
+
17
+ bool compare (laptop i1, laptop i2)
18
+ {
19
+ return (i1.x < i2.x );
20
+ }
21
+
22
+ int main ()
23
+ {
24
+ int n;
25
+ cin >> n;
26
+ vector<laptop> vec (n);
27
+
28
+ for (int i = 0 ; i < n; i++)
29
+ {
30
+ int a, b;
31
+ cin >> a >> b;
32
+ vec[i].x = a;
33
+ vec[i].y = b;
34
+ }
35
+ sort (vec.begin (), vec.end (), compare);
36
+
37
+ cout << endl;
38
+ for (int i = 0 ; i < n; i++)
39
+ {
40
+ cout << vec[i].x << " " << vec[i].y << endl;
41
+ }
42
+
43
+ bool ans = true ;
44
+ for (int i = 1 ; i < n; i++)
45
+ {
46
+ if (vec[i - 1 ].y > vec[i].y )
47
+ {
48
+ ans = false ;
49
+ break ;
50
+ }
51
+ }
52
+
53
+ if (ans)
54
+ cout << " Poor Alex" ;
55
+ else
56
+ cout << " Happy Alex" ;
57
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ author: Ali
3
+ Email: AliGhanbariCs@gmail.com
4
+ GitHub: https://github.com/AliBinary
5
+ created: 28.01.2024 16:01:27
6
+ */
7
+
8
+ #include < iostream>
9
+ using namespace std ;
10
+
11
+ int main ()
12
+ {
13
+ int n, k = 0 ;
14
+ cin >> n;
15
+ int p1, p2, P[2 * n] = {};
16
+ cin >> p1;
17
+ for (int i = 0 ; i < p1; i++)
18
+ {
19
+ int x;
20
+ cin >> x;
21
+ P[k++] = x;
22
+ }
23
+ cin >> p2;
24
+ for (int i = 0 ; i < p2; i++)
25
+ {
26
+ int x;
27
+ cin >> x;
28
+ P[k++] = x;
29
+ }
30
+
31
+ bool ans = true ;
32
+ for (int i = 1 ; i <= n; i++)
33
+ {
34
+ bool flag = true ;
35
+ for (int j = 0 ; j < k; j++)
36
+ {
37
+ if (i == P[j])
38
+ {
39
+ flag = false ;
40
+ break ;
41
+ }
42
+ }
43
+ if (flag)
44
+ {
45
+ ans = false ;
46
+ break ;
47
+ }
48
+ }
49
+
50
+ if (ans)
51
+ cout << " I become the guy." << ' \n ' ;
52
+ else
53
+ cout << " Oh, my keyboard!" ;
54
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ author: Ali
3
+ Email: AliGhanbariCs@gmail.com
4
+ GitHub: https://github.com/AliBinary
5
+ created: 28.01.2024 17:06:59
6
+ */
7
+
8
+ #include < iostream>
9
+ using namespace std ;
10
+
11
+ int main ()
12
+ {
13
+ int a, b, c;
14
+ cin >> a >> b >> c;
15
+
16
+ int l1 = a * b * c,
17
+ l2 = a + b + c,
18
+ l3 = (a + b) * c,
19
+ l4 = a * (b + c);
20
+
21
+ l3 = max (l4, l3);
22
+ l2 = max (l2, l3);
23
+ l1 = max (l1, l2);
24
+ cout << l1;
25
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ author: Ali
3
+ Email: AliGhanbariCs@gmail.com
4
+ GitHub: https://github.com/AliBinary
5
+ created: 28.01.2024 21:15:19
6
+ */
7
+
8
+ #include < iostream>
9
+ #include < math.h>
10
+ using namespace std ;
11
+
12
+ int main ()
13
+ {
14
+ int n, m, ans;
15
+ cin >> n >> m;
16
+ if (n == m)
17
+ ans = 0 ;
18
+ else if (n > m)
19
+ ans = n - m;
20
+ else
21
+ {
22
+ ans = 0 ;
23
+ while (n < m)
24
+ {
25
+ n *= 2 ;
26
+ ans++;
27
+ }
28
+ for (int i = ans; i >= 0 ; i--)
29
+ {
30
+ int dis = n - m;
31
+ int kam = (dis / int (pow (2 , i)));
32
+ ans += kam;
33
+ n -= kam * pow (2 , i);
34
+ }
35
+ }
36
+ cout << ans;
37
+ }
You can’t perform that action at this time.
0 commit comments