// TaskF.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include #include #include #include std::map table; std::vector snum(40); std::vector result; int _tmain(int argc, _TCHAR* argv[]) { unsigned __int64 st = 1; unsigned __int64 nn = 1024; unsigned __int64 tmp; unsigned __int64 i, k, n = 32; unsigned long long res; k = 1i64 << n; for (auto index = 0; index < n; index++) { snum[index] = st; st *= 3; } for (i = 1; ifirst != nn) { do { auto r2 = table.find(r1->first - nn); if (r2 != table.end()) { //std::cout << r1->first << " " << r1->second << std::endl; //std::cout << r2->first << " " << r2->second << std::endl; tmp = r1->second; for (unsigned long index = 0; index < n; index++) { if (tmp % 2) result.push_back(snum[index]); tmp >>= 1; } tmp = r2->second; for (unsigned long index = 0; index < n; index++) { if (tmp % 2) result.push_back(snum[index]); tmp >>= 1; } #ifndef _DEBUG sort(begin(result), end(result)); #endif break; } r1 = ++r1; } while (r1 != table.end()); } else { result.push_back(nn); } std::copy(begin(result), end(result), std::ostream_iterator(std::cout," ")); return 0; }