问满足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. Windows10安装MariaDB

    截至写这篇博客为止,MariaDB官方的稳定版本为,详情访问官方地址:https://downloads.mariadb.org/ 安装之前先简单说一下MariaDB:         MariaDB ...

  2. PHP获取文件后缀的7中方法

    在日常的工作当中我们避免不了要经常获取文件的后缀名,今天我就整理了一下7种获取文件后缀的方法,希望对大家有所帮助. $url = 'http://www.baidu.com/uploads/20185 ...

  3. Python全栈工程师之html学习笔记

    https://www.bilibili.com/video/av15241731 笔记来源:黑马程序员 HTML(Hyper Text Markup Language):超文本标签语言 HTML标签 ...

  4. URI URL URN 关系

    我们一起来看下面这个虚构的例子.这是一个URI: http://bitpoetry.io/posts/hello.html#intro 我们开始分析 http:// 是定义如何访问资源的方式.另外 b ...

  5. DRF filter

    filter 配置 fiter定义 自定义filter继承BaseFilterBackend,必须重写filter_queryset,返回值为过滤后的queryset filter在GenericAP ...

  6. joyoi1864 守卫者的挑战

    #include <algorithm> #include <iostream> #include <cstdio> using namespace std; in ...

  7. C#Windows服务安装

    1,做好windows服务后,生成 一下,然后在项目目录中找到bin文件夹下的Debug文件夹,文件夹下有文件xxxx.exe 2,然后在C:\Windows\Microsoft.NET\Framew ...

  8. 彻底解决python cgi 编程出现的编码问题

    Answering this for late-comers because I don't think that the posted answers get to the root of the ...

  9. Linux 文件/文件夹重命名

    mv命令既可以重命名,又可以移动文件或文件夹. 例子:将目录A重命名为Bmv A B 例子:将/a目录移动到/b下,并重命名为cmv /a /b/c 其实在文本模式中要重命名文件或目录,只需要使用mv ...

  10. 【机房收费系统 4】:VB获取标准北京时间,免除时间误差

    导读:这又是师傅给我指出的一个问题,说实话,其实开始根本没有当回事,觉得麻烦,可是,等我完成了获取标准北京时间后,我发现,这一步,是必须的.谢谢师傅对我的严格要求,让我一步一步的成长起来! 一.事件缘 ...