C++题目描述魔方大家都玩过吧? 常见的魔方每边上有 33 个小正方体如下图所示:file20181008060222_20181008jpg我们把魔方每边上的小正方体数量叫魔方的阶所以常见的魔方叫3阶魔方。 不过魔方可不是只有 33 阶的还有 2、4、52、4、5……阶的呢如下图所示:file20181008060240_20181008jpg观察所有的魔方你会发现我们可以把魔方表面上的小正方体
#include
int main() { int n; cin >> n;
int first_class = 4 * (n - 1) * (n - 2); // 第一类小正方体的数量
int second_class = 4 * (n - 1) + 4 * (n - 2); // 第二类小正方体的数量
int third_class = 8; // 第三类小正方体的数量
cout << first_class << endl;
cout << second_class << endl;
cout << third_class << endl;
return 0;
}
原文地址: https://www.cveoy.top/t/topic/iWPR 著作权归作者所有。请勿转载和采集!