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

洛谷 P2911 [USACO08OCT]Bovine Bones G 更多...

#include <luogu.h>

静态 Public 成员函数

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

详细描述

洛谷 P2911 [USACO08OCT]Bovine Bones G

在文件 luogu.h443 行定义.

成员函数说明

◆ main()

int luogu::P2911::main ( istream &  cin,
ostream &  cout 
)
static

在文件 luogu.cpp1454 行定义.

1454 {
1455 int s1;
1456 int s2;
1457 int s3;
1458 cin >> s1 >> s2 >> s3;
1459 const int n = s1 + s2 + s3 + 1;
1460 auto *sum = new int[n];
1461 memset(sum, 0, n * sizeof(int));
1462 for(int i = 1; i <= s1; i++) {
1463 for(int j = 1; j <= s2; j++) {
1464 for(int k = 1; k <= s3; k++) {
1465 sum[i + j + k]++;
1466 }
1467 }
1468 }
1469 int maximum = 0;
1470 int ans = 0;
1471 for(int i = 3; i < n; i++) {
1472 if(maximum < sum[i]) {
1473 maximum = sum[i];
1474 ans = i;
1475 }
1476 }
1477 cout << ans;
1478 delete[] sum;
1479 return 0;
1480 }

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


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