问满足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
*/
}

Croc Champ 2013 - Round 2 C. Cube Problem的更多相关文章

  1. Croc Champ 2013 - Round 1 E. Copying Data 分块

    E. Copying Data time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  2. Croc Champ 2013 - Round 1 E. Copying Data 线段树

    题目链接: http://codeforces.com/problemset/problem/292/E E. Copying Data time limit per test2 secondsmem ...

  3. D. Connected Components Croc Champ 2013 - Round 1 (并查集+技巧)

    292D - Connected Components D. Connected Components time limit per test 2 seconds memory limit per t ...

  4. codeforces 299E Cube Problem

    Cube Problem Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit   Stat ...

  5. Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) D - Dynamic Problem Scoring

    地址:http://codeforces.com/contest/807/problem/D 题目: D. Dynamic Problem Scoring time limit per test 2 ...

  6. Codeforces Beta Round #2 C. Commentator problem 模拟退火

    C. Commentator problem 题目连接: http://www.codeforces.com/contest/2/problem/C Description The Olympic G ...

  7. Codeforces Round #716 (Div. 2), problem: (B) AND 0, Sum Big位运算思维

    & -- 位运算之一,有0则0 原题链接 Problem - 1514B - Codeforces 题目 Example input 2 2 2 100000 20 output 4 2267 ...

  8. Codeforces Beta Round #17 A - Noldbach problem 暴力

    A - Noldbach problem 题面链接 http://codeforces.com/contest/17/problem/A 题面 Nick is interested in prime ...

  9. CROC 2016 - Final Round [Private, For Onsite Finalists Only] C. Binary Table FWT

    C. Binary Table 题目连接: http://codeforces.com/problemset/problem/662/C Description You are given a tab ...

随机推荐

  1. python爬虫---实现项目(三) Selenium分析美团美食

    上一期博客,我本来想爬取美团美食的,但是由于请求头太复杂,没有破解开其中的几个参数,所以放弃,这次我们来用selenium来模式浏览器抓取数据,我们先来简单看一下流程: 1,利用selenium驱动浏 ...

  2. Vue的安装并在WebStorm中运行

    一.Vue的安装需要两个支持分别为:nodejs.npm Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境. Node.js 使用了一个事件驱动.非阻塞式 I/O ...

  3. thinkphp 结合phpexcel实现excel导入

    控制器文件: class ExcelAction extends Action { public function __construct() { import('ORG.Util.ExcelToAr ...

  4. mac拷贝原版和权限修复的命令行工具

    建议直接从安装盘中用命令复制,因为上传的kext权限会变,导致签名失败. 假定安装盘盘符是install_osx: sudo cp -R /Volumes/install_osx/S*/L*/E*/A ...

  5. js截屏

    <html><head> <meta name="layout" content="main"> <meta http ...

  6. LeetCode 最长连续递增序列

    给定一个未经排序的整数数组,找到最长且连续的的递增序列. 示例 1: 输入: [1,3,5,4,7] 输出: 3 解释: 最长连续递增序列是 [1,3,5], 长度为3. 尽管 [1,3,5,7] 也 ...

  7. bzoj5469 [FJOI2018]领导集团问题

    题目描述: bz luogu 题解: 相当于树上$LIS$问题. 考虑一维情况下的贪心,我们可以用multiset启发式合并搞. 代码: #include<set> #include< ...

  8. 初涉2-SAT

    2-SAT:有趣的图论模型 什么是2-SAT SAT是适定性(Satisfiability)问题的简称.之所以研究2-sat是因为当k>2时,k-sat问题已经被证明是NPC的了. 2-sat问 ...

  9. python的部分内置函数

    内置函数思维导图:https://www.processon.com/mindmap/5c10ca52e4b0c2ee256ac034 内置函数 匿名函数 匿名函数统一的名字是:<lambda& ...

  10. Python数据类型(简单入门)

    数据类型(预了解) 1.数字类型 整型:int 即不带小数点的数,通常用来标识年龄,账号,身份证号,等级等整数. 浮点型:float 即带有小数点的数,通常用来标记身高,体重,科学计算等有小数点的数. ...