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

AcWing 1443. 拍照 更多...

#include <acwing.h>

静态 Public 成员函数

static int main (istream &cin, ostream &cout)
 

详细描述

AcWing 1443. 拍照

在文件 acwing.h1229 行定义.

成员函数说明

◆ main()

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

在文件 acwing.cpp3946 行定义.

3946 {
3947 int n;
3948 cin >> n;
3949 auto *a = new int[n];
3950 auto *b = new int[n - 1];
3951 for(int i = 0; i < n - 1; i++) {
3952 cin >> b[i];
3953 }
3954 for(int i = 1; i <= n; i++) {
3955 auto us = unordered_set<int>();
3956 bool flag = true;
3957 a[0] = i;
3958 for(int j = 1; j < n; j++) {
3959 a[j] = b[j - 1] - a[j - 1];
3960 if(us.contains(a[j]) || a[j] <= 0) {
3961 flag = false;
3962 break;
3963 }
3964 us.insert(a[j]);
3965
3966 us.insert(a[j]);
3967 }
3968 if(flag) {
3969 for(int j = 0; j < n; j++) {
3970 cout << a[j] << " ";
3971 }
3972 break;
3973 }
3974 }
3975 delete[] b;
3976 delete[] a;
3977 return 0;
3978 }

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


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