Mahmoud_Hawara

Contest #3 - Solution

Nov 14th, 2025
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.16 KB | None | 0 0
  1. ////////////////////////////////////////// PROBLEM - A //////////////////////////////////////////
  2. #include <bits/stdc++.h>
  3. #define ll long long
  4. using namespace std;
  5.  
  6. void solve()
  7. {
  8.     int n, k;
  9.     cin >> n >> k;
  10.     char c = 'a';
  11.     for (int i = 0, j = 1; i < n; i++, j++) {
  12.         cout << c;
  13.         if (j % k == 0) c = 'a';
  14.         else c++;
  15.     }
  16. }
  17.  
  18. int main()
  19. {
  20.     int t = 1;
  21.     // cin >> t;
  22.     for (int i = 1; i <= t; i++)
  23.     {
  24.         solve();
  25.     }
  26.     return 0;
  27. }
  28.  
  29.  
  30.  
  31. ////////////////////////////////////////// PROBLEM - B //////////////////////////////////////////
  32. #include <bits/stdc++.h>
  33. #define ll long long
  34. using namespace std;
  35.  
  36. void solve()
  37. {
  38.     int k, r;
  39.     cin >> k >> r;
  40.     for (int i = 1; i <= 10; i++) {
  41.         int x = i * k;
  42.         if (x % 10 == r || x % 10 == 0) {
  43.             cout << i;
  44.             break;
  45.         }
  46.     }    
  47. }
  48.  
  49. int main()
  50. {
  51.     int t = 1;
  52.     // cin >> t;
  53.     for (int i = 1; i <= t; i++)
  54.     {
  55.         solve();
  56.     }
  57.     return 0;
  58. }
  59.  
  60.  
  61.  
  62. ////////////////////////////////////////// PROBLEM - C //////////////////////////////////////////
  63. #include <bits/stdc++.h>
  64. #define ll long long
  65. using namespace std;
  66.  
  67. void solve()
  68. {
  69.     int n;
  70.     string s;
  71.     cin >> n >> s;
  72.     int anton = 0;
  73.     int danik = 0;
  74.     for (int i = 0; s[i]; i++) {
  75.         if (s[i] == 'A') anton++;
  76.         else danik++;
  77.     }
  78.     if (anton > danik) cout << "Anton";
  79.     else if (anton < danik) cout << "Danik";
  80.     else cout << "Friendship";
  81. }
  82.  
  83. int main()
  84. {
  85.     int t = 1;
  86.     // cin >> t;
  87.     for (int i = 1; i <= t; i++)
  88.     {
  89.         solve();
  90.     }
  91.     return 0;
  92. }
  93.  
  94.  
  95.  
  96. ////////////////////////////////////////// PROBLEM - D //////////////////////////////////////////
  97. #include <bits/stdc++.h>
  98. #define ll long long
  99. using namespace std;
  100.  
  101. void solve()
  102. {
  103.     int n;
  104.     cin >> n;
  105.     int a[n + 1];
  106.     for (int i = 1; i <= n; i++) {
  107.         cin >> a[i];
  108.     }
  109.     int score0 = 0, score1 = 0;
  110.     bool player = 0;
  111.     for (int i = 1, j = n; i <= j; player = 1 - player) {
  112.         int mx;
  113.         if (a[i] >= a[j]) {
  114.             mx = a[i];
  115.             i++;
  116.         }
  117.         else {
  118.             mx = a[j];
  119.             j--;
  120.         }
  121.         if (player == 0) score0 += mx;
  122.         else score1 += mx;
  123.     }
  124.     cout << score0 << ' ' << score1;
  125. }
  126.  
  127. int main()
  128. {
  129.     int t = 1;
  130.     // cin >> t;
  131.     for (int i = 1; i <= t; i++)
  132.     {
  133.         solve();
  134.     }
  135.     return 0;
  136. }
  137.  
  138.  
  139.  
  140. ////////////////////////////////////////// PROBLEM - E //////////////////////////////////////////
  141. #include <bits/stdc++.h>
  142. #define ll long long
  143. using namespace std;
  144.  
  145. void solve()
  146. {
  147.     string s1, s2;
  148.     cin >> s1 >> s2;
  149.     for (int i = 0; s1[i]; i++) {
  150.         s1[i] = tolower(s1[i]);
  151.         s2[i] = tolower(s2[i]);
  152.     }
  153.     if (s1 == s2) cout << 0;
  154.     else if (s1 > s2) cout << 1;
  155.     else cout << -1;
  156. }
  157.  
  158. int main()
  159. {
  160.     int t = 1;
  161.     // cin >> t;
  162.     for (int i = 1; i <= t; i++)
  163.     {
  164.         solve();
  165.     }
  166.     return 0;
  167. }
  168.  
  169.  
  170.  
  171. ////////////////////////////////////////// PROBLEM - F //////////////////////////////////////////
  172. #include <bits/stdc++.h>
  173. #define ll long long
  174. using namespace std;
  175.  
  176. void solve()
  177. {
  178.     int n;
  179.     cin >> n;
  180.     int a[n + 1][2];
  181.     for (int i = 1; i <= n; i++) {
  182.         cin >> a[i][0] >> a[i][1];
  183.     }    
  184.     int ans = 0;
  185.     for (int i = 1; i <= n; i++) {
  186.         for (int j = i + 1; j <= n; j++) {
  187.             if (a[i][0] == a[j][1]) ans++;
  188.             if (a[i][1] == a[j][0]) ans++;
  189.         }
  190.     }
  191.     cout << ans;
  192. }
  193.  
  194. int main()
  195. {
  196.     int t = 1;
  197.     // cin >> t;
  198.     for (int i = 1; i <= t; i++)
  199.     {
  200.         solve();
  201.     }
  202.     return 0;
  203. }
  204.  
  205.  
  206.  
  207. ////////////////////////////////////////// PROBLEM - G //////////////////////////////////////////
  208. #include <bits/stdc++.h>
  209. #define ll long long
  210. using namespace std;
  211.  
  212. void solve()
  213. {
  214.     string s1, s2;
  215.     cin >> s1 >> s2;
  216.     int i = 0;
  217.     for (int j = 0; s2[j]; j++) {
  218.         if (s1[i] == s2[j]) i++;
  219.     }
  220.     cout << i + 1;
  221. }
  222.  
  223. int main()
  224. {
  225.     int t = 1;
  226.     // cin >> t;
  227.     for (int i = 1; i <= t; i++)
  228.     {
  229.         solve();
  230.     }
  231.     return 0;
  232. }
Advertisement
Add Comment
Please, Sign In to add comment