problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
acwing::acwing2058类 参考

#include <acwing.h>

静态 Public 成员函数

static int main (istream &, ostream &)
 

详细描述

在文件 acwing.h82 行定义.

成员函数说明

◆ main()

int acwing::acwing2058::main ( istream &  cin,
ostream &  cout 
)
static

在文件 acwing.cpp233 行定义.

233 {
234 string n2;
235 string n3;
236 cin >> n2 >> n3;
237 auto s = set<long long>();
238
239 for(int i = 0; i < n2.length(); i++) {
240 long long val = 0;
241 for(int j = 0; j < n2.length(); j++) {
242 bool bit = n2[j] != '0';
243 if(j == i) {
244 bit = !bit;
245 }
246 if(bit) {
247 val += static_cast<long long>(pow(2, n2.size() - j - 1));
248 }
249 }
250 s.insert(val);
251 }
252
253 for(int n = 1; n <= 2; n++) {
254 for(int i = 0; i < n3.length(); i++) {
255 long long val = 0;
256 for(int j = 0; j < n3.length(); j++) {
257 int v = n3[j] - '0';
258 if(i == j) {
259 v += n;
260 v %= 3;
261 }
262 val += static_cast<long long>(v * pow(3, n3.size() - j - 1));
263 }
264 if(s.contains(val)) {
265 cout << val;
266 return 0;
267 }
268 s.insert(val);
269 }
270 }
271 return 0;
272 }

被这些函数引用 acwing::TEST().


该类的文档由以下文件生成: