第十二届蓝桥杯省赛C&C++ 研究生组-货物摆放

还是整数分解问题,注意n本身也是约数

cpp 复制代码
#include <iostream>
int main(){
  printf("2430");
  return 0;
}
cpp 复制代码
#include <iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll n = 2021041820210418LL;
const ll maxn = 44955998;
ll p[maxn] = {1};
int main(){
  ll sqr = (ll) sqrt(n), count = 0, num = 1;//126432 44955998
  for(int i = 2; i <= sqr; i++){
  	if(n % i == 0){
  		p[num++] = i;
  		if(i * i != n) p[num++] = n / i;
	  }
  }
  p[num] = n;	
  for(int i = 0; i <= num; i++){
  	for(int j = 0; j <= num; j++){
  		for(int k = 0; k <= num; k++){
  			if(p[i]*p[j]*p[k] == n) {
  				count++;
  				printf("%lld %lld %lld\n", p[i], p[j], p[k]);
			  }
		  }
	  }
  }
  printf("%lld", count);
  return 0;
}
相关推荐
卷无止境2 天前
C++ 的Eigen 库全解析
c++
卷无止境2 天前
现代 C++特性大盘点:一门脱胎换骨的老语言
c++·后端
郝学胜_神的一滴2 天前
CMake 27:缓存变量的特性、语法、类型与实操全解
c++·cmake
博客18004 天前
酷宝的使用方法,超好用的免费界面库,C++、MFC可用
c++·mfc·界面库·库来帮·酷宝
郝学胜_神的一滴4 天前
CMake 026:属性体系精讲、四大作用域全解 & 实战代码落地
c++·cmake
众少成多积小致巨4 天前
JNI (Java Native Interface) 技术手册中文参考指南
android·java·c++
clint4568 天前
C++进阶(1)——前景提要
c++
夜悊9 天前
C++代码示例:进制数简单生成工具
c++
郝学胜_神的一滴9 天前
CMake 021: IF 条件判据详诠
c++·cmake
_wyt0019 天前
洛谷 B3930 [GESP202312 五级] 烹饪问题 题解
c++·gesp