Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int,int>
- #define vec vector
- using namespace std;
- using ll = long long;
- using ld = long double;
- using db = double;
- void cv(vector <int> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvl(vector <ll> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvv(vector <vector <int> > &v){
- for (auto x: v) cv(x);
- cout<<"\n";
- }
- void cvb(vector <bool> v){
- for (bool x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvs(vector <string> v){
- for (auto a: v){
- cout<<a<<"\n";
- }
- }
- string to2(int x){
- string r="";
- while (x > 0){
- r += x % 2 + '0';
- x/=2;
- }
- reverse(r.begin(), r.end());
- while (r.size() < 4){
- r = '0' + r;
- }
- return r;
- }
- string fr16to2(vector <int> v){
- //v идет с конца к началу -- от последней цифры до первой
- string r = "";
- for (int i = 0; i < 16; ++i){
- string x = to2(v[i]);
- reverse(x.begin(), x.end());
- r += x;
- }
- //reverse(r.begin(), r.end());
- return r;
- }
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- vector <int> v;
- for (int i = 0; i < 16;++i){
- string s; cin>>s;
- if (s == "stop")break;
- int a,b;
- a = s[0] - '0';
- b = s[1] - '0';
- //cout<<a<<' '<<b<<"\n";
- v.push_back(b * 4+ a);
- }
- //reverse(v.begin(), v.end());
- //cv(v);
- //cout<<to2(18);
- string res = fr16to2(v);
- cout<<res<<"\n";
- //reverse(res.begin)
- int ans=0;
- for (int i = 0; i < 64;++i){
- if (i % 3 == 0){
- ans += res[i] - '0';
- }
- }
- cout<<ans<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement