问满足a^3 + b^3 + c^3 + n = (a+b+c)^3 的 (a,b,c)的个数

可化简为 n = 3*(a + b) (a + c) (b + c)

于是 n / 3 = (a + b)(a + c) (b + c)

令x = a + b,y = a + c,z = b + c,s = n / 3

s = xyz

并且令x <= y <= z,于是我们解s = xyz这个方程,可以枚举x,y得到z。

得到(x,y,z)后便可以得到a,b,c但可能有不符合条件的三元组,化简系数矩阵

1  1  0    由于枚举时已满足x <= y <= z   2  0  0 x + y - z >= 0,即 x + y >= z

1  0  1                                      1  0  1

0  1  1                    0  1  1

另外如果x = y = z时此时只贡献了一个答案,如果x = y || y = z 答案只贡献了3个

其余贡献了6个

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>
#include <stack>
using namespace std;
typedef long long ll;
#define T int t_;Read(t_);while(t_--)
#define dight(chr) (chr>='0'&&chr<='9')
#define alpha(chr) (chr>='a'&&chr<='z')
#define INF (0x3f3f3f3f)
#define maxn (2000005)
#define maxm (10005)
#define mod 1000000007
#define ull unsigned long long
#define repne(x,y,i) for(int i=(x);i<(y);++i)
#define repe(x,y,i) for(int i=(x);i<=(y);++i)
#define repde(x,y,i) for(int i=(x);i>=(y);--i)
#define repdne(x,y,i) for(int i=(x);i>(y);--i)
#define ri register int
inline void Read(int &n){char chr=getchar(),sign=;for(;!dight(chr);chr=getchar())if(chr=='-')sign=-;
for(n=;dight(chr);chr=getchar())n=n*+chr-'';n*=sign;}
inline void Read(ll &n){char chr=getchar(),sign=;for(;!dight(chr);chr=getchar())if
(chr=='-')sign=-;
for(n=;dight(chr);chr=getchar())n=n*+chr-'';n*=sign;}
ll n;
int powx(int c,ll t){
ll l = ,r = sqrt(t);
while(l <= r){
ll mid = (l + r) >> ,s = ;
repe(,c,i) s *= mid;
if(s > t) r = mid - ;
else if(s < t) l = mid + ;
else return (int)mid;
}
return (int)r;
}
int main()
{
//freopen("a.in","r",stdin);
//freopen("b.out","w",stdout);
Read(n);
if(n % ){
puts("");
return ;
}
n /= ;
int lix = powx(,n);
int ans = ;
repe(,lix,x){
if(n % x) continue;
ll nx = n / x;
int liy = powx(,nx);
repde(liy,x,y){
if(nx % y) continue;
int z = nx / y;
if(x + y <= z) break;
if((x + y + z) & ) continue;
if(x == y && y == z) ++ans;
else if(x == y || y == z) ans += ;
else ans += ;
}
}
cout << ans << endl;
return ;
/*
t = a + b
(a-b)^2 + 4s/t = k^2
*/
}

最新文章

  1. Intellij IDEA Java web 项目搭建
  2. jquery中prop()方法和attr()方法的区别浅析
  3. 微信成为开发者C#代码
  4. django 简单的邮件系统
  5. Python文件处理之文件写入方式与写缓存(三)
  6. Cassandra1.2文档学习(7)—— 规划集群部署
  7. WPF - Build Error总结
  8. tp框架中的静态验证
  9. card card card HDU - 6205
  10. 【数据库】mysql深入理解乐观锁与悲观锁
  11. [LeetCode] 4 Keys Keyboard 四键的键盘
  12. leetcode 226 Invert Binary Tree 翻转二叉树
  13. linux下压缩解压缩命令
  14. IntelliJ IDEA 的下载和安装
  15. NOIP2018联赛总结
  16. key-event
  17. 使用python解决算法和数据结构--使用栈实现符号匹配
  18. GPUImage每个类的作用
  19. 关于Java IO与NIO知识都在这里
  20. js 中时间格式化的几种方法

热门文章

  1. Windows MinGW 64-bit boost 踩坑
  2. Evaluate|GC content|Phred|BAC|heterozygous single nucleotide polymorphisms|estimate genome size|
  3. SQL 牛刀小试 1 —— 查询操作
  4. (50)zabbix API二次开发使用与介绍
  5. (20)zabbix触发器triggers
  6. Ubuntu中安装配置 JDK与apache
  7. Python第三方库之openpyxl(10)
  8. HDU 2435 There is a war
  9. Leetcode 324.摆动排序II
  10. 【Kubernetes】声明式API与Kubernetes编程范式