codeforces 299E Cube Problem
Time Limit:2000MS
Memory Limit:262144KB
64bit IO Format:%I64d & %I64u Submit Status Practice
CodeForces 299E
Description Yaroslav, Andrey and Roman love playing cubes. Sometimes they get together and play cubes for hours and hours!
Today they got together again and they are playing cubes. Yaroslav took unit cubes and composed them into an a?×?a?×?a cube, Andrey made a b?×?b?×?b cube and Roman made a c?×?c?×?c cube. After that the game was finished and the guys left. But later, Vitaly entered the room. He saw the cubes and wanted to make a cube as well. But what size should the cube be? Of course it should be a large cube with the side of length a?+?b?+?c. Besides, Vitaly decided to decompose the cubes built by Yaroslav, Andrey and Roman and compose his own large cube out of them. However, it turned out that the unit cubes he got from destroying the three cubes just weren't enough to make a large cube. We know that Vitaly was short of exactly n cubes. Vitaly got upset, demolished everything and left. As he was leaving, he met Petya and told him that there had been three cubes in the room and that he needed another n unit cubes to make his own large cube.
Petya entered the room and saw the messily scattered cubes. He wanted to make it neat and orderly again. But he only knows that there had been three cubes, made of small unit cubes and that Vitaly needed n more unit cubes to make a large one! Help Petya understand, how many ways of sizes a, b, c are there to restore Yaroslav's, Andrey's and Roman's cubes.
Input The single line of the input contains integer n (1?≤?n?≤?10^14). We know that all numbers a, b, c are positive integers.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
Output In the single line print the required number of ways. If it turns out that there isn't a single way of suitable sizes of a, b, c, print 0.
Sample Input
Input 24
Output 1
Input 648
Output 7
Input 5
Output 0
Input 93163582512000
Output 39090
/*
n数量级为10^14
题意:(a+b+c)^3-(a^3+b^3+c^3)=n; 化简即为:3*(a+b)*(b+c)*(c+a)=n;
显然n必须mod 3 即为(a+b)*(b+c)*(c+a)=n;(n/=3)
令i=(a+b);j=(b+c);k=(c+a);x^3=n;(i,j,k可以构成三角形!!)
枚举i(1-x);
令a=n/i;(n%i==0)
i+j>k;(1)
j*k=a;(2)
两式消k得:(j+i/2)^2>a+(i/2)^2; 令h=sqrt(a+i/2)^2)-i/2;//核心!!!!
由(2)知j*j<a(j<k)即为j<sqrt(a);
故j枚举范围为:min(i,h)-sqrt(a);
大功告成!!!
*/
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
__int64 x,n;
int i,j,a,b,c,y,k,q,p,ans;
scanf("%I64d",&n);
if(n%)
{
printf("0\n");
return ;
}
n=n/; x=; ans=;
while((x+)*(x+)*(x+)<=n)
x++;
for(i=;i<=int(x);i++)
{
if(n%i) continue;
y=sqrt(n/i);q=(sqrt(i*i+*n/i)-i)/;
for(j=i>q?i:q;j<=y;j++)
{
k=n/i/j;
if(k<j) break;
if(n/i%j) continue;
if((i+j+k)%)continue;
p=(i+j+k)/;
a=p-i; b=p-j; c=p-k;
if(a<||b<||c<) continue;
if(a==b&&b==c) ans++;
else if(a==b||b==c) ans+=;
else ans+=;
}
}
printf("%d\n",ans);
return ;
}
codeforces 299E Cube Problem的更多相关文章
- codeforces 340C Tourist Problem
link:http://codeforces.com/problemset/problem/340/C 开始一点也没思路,赛后看别人写的代码那么短,可是不知道怎么推出来的啊! 后来明白了. 首先考虑第 ...
- codeforces B. Routine Problem 解题报告
题目链接:http://codeforces.com/problemset/problem/337/B 看到这个题目,觉得特别有意思,因为有熟悉的图片(看过的一部电影).接着让我很意外的是,在纸上比划 ...
- Codeforces 527D Clique Problem
http://codeforces.com/problemset/problem/527/D 题意:给出一些点的xi和wi,当|xi−xj|≥wi+wj的时候,两点间存在一条边,找出一个最大的集合,集 ...
- Codeforces 706C - Hard problem - [DP]
题目链接:https://codeforces.com/problemset/problem/706/C 题意: 给出 $n$ 个字符串,对于第 $i$ 个字符串,你可以选择花费 $c_i$ 来将它整 ...
- Codeforces 1096D - Easy Problem - [DP]
题目链接:http://codeforces.com/problemset/problem/1096/D 题意: 给出一个小写字母组成的字符串,如果该字符串的某个子序列为 $hard$,就代表这个字符 ...
- Codeforces 793C - Mice problem(几何)
题目链接:http://codeforces.com/problemset/problem/793/C 题目大意:给你一个捕鼠器坐标,和各个老鼠的的坐标以及相应坐标的移动速度,问你是否存在一个时间点可 ...
- CodeForces 687A NP-Hard Problem
Portal:http://codeforces.com/problemset/problem/687/A 二分图染色 好模板题 有SPJ 值得注意的是,因为C++的奇妙的运算机制 若在vector变 ...
- Codeforces Gym 100342J Problem J. Triatrip 求三元环的数量 bitset
Problem J. Triatrip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...
- Codeforces Gym 100342C Problem C. Painting Cottages 转化题意
Problem C. Painting CottagesTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...
随机推荐
- 基于DRF的图书增删改查练习
功能演示 信息展示 添加功能 编辑功能 删除功能 DRF构建后台数据 本例的Model如下 from django.db import models class Publish(models.Mode ...
- leetcode-mid-sorting and searching - 56 Merge Intervals
mycode 出现的问题:比如最后一个元素是[1,10],1小于前面所有元素的最小值,10大于前面所有元素的最大值,而我最开始的思路只考虑了相邻 参考: 思路:如果我只考虑相邻,必须先将list排序, ...
- 歌手详情数据处理和Song类的封装
我们现在每首歌曲的数据都是这样的 我们需要在这个数据里面去提取我们需要的部分,来构造成我们需要的数据对象 那我们要和创建singer.js一样 同样也要创建song.js类 我们还要获取到每首歌对应 ...
- Delphi XE2 之 FireMonkey 入门(31) - 数据绑定: 绑定数据库
Delphi XE2 之 FireMonkey 入门(31) - 数据绑定: 绑定数据库 一.全设计时操作: 先在窗体上放置控件: DataSource1 : TDataSource; Clie ...
- Unity ZTest 深度测试 & ZWrite 深度写入
初学Shader,一开始对于渲染队列,ZTest 和 ZWrite一头雾水,经过多方查阅和实验,有了一些自己的理解.发此文与初学Shader的朋友分享,也算是为自己做个笔记.不对或不足之处欢迎指正. ...
- linux 学习笔记二
笔记二 命令行格式 command [-options] parameter1 parameter2 ... 命令 选项 参数(1) 参数(2) options 和 参数 不是必须的 帮助命令 man ...
- laravel 配置双模板引擎
有时候我们可能有这种需求,pc 和 mobile 端显示的页面不一样,这个时候,我们就需要判断设备类型: ****我们用 composer require whichbrowser/parser ...
- charles抓包教程
百度搜索下载charles 默认安装即可完成 1.双击charles.exe启动,我的是4.2.7版本.最好下载原版的不要去破解中文,会有不兼容 1.搜索该软件许可证书并输入即可长期使用 2.设置代理 ...
- 如何面对这个残酷的世界?——Java模拟
1,问题引入: 房间里有100个人,每人都有100元钱,他们在玩一个游戏.每轮游戏中,每个人都要拿出一元钱随机给另一个人,最后这100个人的财富分布是怎样的? 2,问题思考: 今天有幸看到这道题目,起 ...
- 5G的科普
5G的科普 1. 通信起源公式 2. 5G在有线与无线的应用 主要在无线上的突破 因为有线也就是(电缆,光纤,双绞线)这些传输介质,特别是光纤,以及完全达到我们平时通信所需求的速率 那么瓶颈在哪?短板 ...