john2323

BAC 2021 TEST 3 ANTRENAMENT INFO

Mar 8th, 2021 (edited)
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.00 KB | None | 0 0
  1. I.
  2. 1.b
  3. 2.c
  4. 3.b
  5. 4.a
  6. 5.d
  7.  
  8. II.
  9. 1.
  10. a.
  11. 250887
  12. b.
  13. 22 44
  14. c.
  15. #include <bits/stdc++.h>
  16.  
  17. using namespace std;
  18.  
  19. int main() {
  20.   int n, cn, x, m, p, c;
  21.   cin >> n;
  22.   x = 0;
  23.   m = 0;
  24.   p = 1;
  25.   while (x < 10) {
  26.     cn = n;
  27.     while (cn != 0) {
  28.       c = cn % 10;
  29.       cn = cn / 10;
  30.       if (c == x) {
  31.         m = c * p + m;
  32.         p = p * 10;
  33.       }
  34.     }
  35.     x = x + 2;
  36.   }
  37.   cout << m;
  38.   return 0;
  39. }
  40. d.
  41. -
  42. 2.
  43. struct{int numar;
  44.        struct{int nume[21];
  45.               int colectie[21];}exponat[20];
  46.                       }m;
  47. 3.
  48. un
  49. zeu
  50.  
  51. III.
  52. 1.
  53. int prim(int n) {
  54.   int j;
  55.   if (n == 1 || n == 0)
  56.     return 0;
  57.   if (n == 2)
  58.     return 1;
  59.   if (n % 2 == 0)
  60.     return 0;
  61.   for (j = 3; j < n; j = j + 2)
  62.     if (n % j == 0)
  63.       return 0;
  64.   return 1;
  65. }
  66.  
  67. int suma(int n) {
  68.   int s = 0, i, d;
  69.   for (i = 1; i * i <= n; i++) {
  70.     if (n % i == 0) {
  71.       if (prim(i) == 0)
  72.         s = s + i;
  73.       if (i * i < n) {
  74.         if (prim(n / i) == 0)
  75.           s = s + n / i;
  76.       }
  77.     }
  78.   }
  79.   return s;
  80. }
  81.  
  82. 2.
  83. #include <bits/stdc++.h>
  84.  
  85. using namespace std;
  86. int ap[401];
  87. int main() {
  88.   int n, m, ok = 0, i, j, x, maxi = 2e-9, mini = 2e9;
  89.   cin >> m >> n;
  90.   for (i = 1; i <= m; i++)
  91.     for (j = 1; j <= n; j++) {
  92.       cin >> x;
  93.       if (j == 1 || j == n) {
  94.         maxi = max(maxi, x);
  95.         mini = min(mini, x);
  96.         ap[x]++;
  97.       }
  98.     }
  99.   for (i = mini; i <= maxi; i++)
  100.     if (ap[i] == 2) {
  101.       cout << i << " ";
  102.       ok = 1;
  103.     }
  104.   if (ok == 0)
  105.     cout << "nu exista";
  106.   return 0;
  107. }
  108.  
  109. 3.
  110. #include <bits/stdc++.h>
  111.  
  112. using namespace std;
  113. ifstream fin("bac.in");
  114. long long v[10], ap[10];
  115. int main() {
  116.   int x, maxi = 2e-9, i = 0, loc = 0;
  117.   while (fin >> x) {
  118.     i++;
  119.     x /= 10;
  120.     ap[x % 10]++;
  121.     if (ap[x % 10] == maxi)
  122.       v[++loc] = i;
  123.     else
  124.     if (ap[x % 10] > maxi) {
  125.       maxi = ap[x % 10];
  126.       loc = 0;
  127.       v[++loc] = i;
  128.     }
  129.   }
  130.   for (i = 1; i <= loc; i++)
  131.     cout << v[i] << " ";
  132.   return 0;
  133. }
Add Comment
Please, Sign In to add comment