-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path6dz.cpp
More file actions
36 lines (35 loc) · 702 Bytes
/
6dz.cpp
File metadata and controls
36 lines (35 loc) · 702 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <set>
#include <vector>
//àëãîðèòì ýôôåêòèâíûé,òàê êàê ìû ââîäèì è âûâîäèì ÷èñëà â 1 öèêëå,ò.å. ïðè ââîäå
//ìû ñðàçó îïðåäåëÿåì íóæíûé ýëåìåíò è íåíóæíûé
using namespace std;
int SUM = 0;
void FindTroiki(int n, int r)
{
int temp = n;
int counter = 0;
while (temp > 0)
{
if (temp % 3 == 2)
counter++;
temp /= 3;
}
SUM += counter;
if (counter < r)
cout <<"number of array: "<<n<<endl;
}
int main()
{
int r; cin >> r;
int n; cin >> n;
vector<int> arr(n);
for (int i = 0; i < arr.size(); i++)
{
cout << "enter the element: ";
cin >> arr[i];
FindTroiki(arr[i], r);
}
cout <<"number of twos: "<< SUM;
return 0;
}