第十二届蓝桥杯省赛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;
}
相关推荐
郝学胜-神的一滴1 分钟前
深入浅出网络协议:从OSI七层到TCP/IP五层模型全解析
开发语言·网络·c++·网络协议·tcp/ip·程序人生
夏乌_Wx4 分钟前
练题100天——DAY39:单链表练习题×5
c语言·数据结构·算法·链表
jojo_zjx13 分钟前
GESP 25年12月1级 手机电量显示
c++
blueSatchel16 分钟前
bus_register源码研究
linux·c语言
程序员zgh21 分钟前
C语言 弱定义机制 解读
c语言·开发语言·c++
宵时待雨35 分钟前
数据结构(初阶)笔记归纳6:双向链表的实现
c语言·开发语言·数据结构·笔记·算法·链表
FMRbpm42 分钟前
树的练习7--------LCR 052.递增顺序搜索树
数据结构·c++·算法·leetcode·深度优先·新手入门
余衫马1 小时前
Qt for Python:PySide6 入门指南(中篇)
开发语言·c++·python·qt
明洞日记1 小时前
【软考每日一练007】位图计算与内存管理深度全解
c++·算法·ai·操作系统·进程
张张努力变强1 小时前
C++ 类和对象(二):实例化、this指针、构造函数、析构函数详解
开发语言·c++