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);

大功告成!!!

*/

  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<algorithm>
  4. using namespace std;
  5. int main()
  6. {
  7. __int64 x,n;
  8. int i,j,a,b,c,y,k,q,p,ans;
  9. scanf("%I64d",&n);
  10. if(n%)
  11. {
  12. printf("0\n");
  13. return ;
  14. }
  15. n=n/; x=; ans=;
  16. while((x+)*(x+)*(x+)<=n)
  17. x++;
  18. for(i=;i<=int(x);i++)
  19. {
  20. if(n%i) continue;
  21. y=sqrt(n/i);q=(sqrt(i*i+*n/i)-i)/;
  22. for(j=i>q?i:q;j<=y;j++)
  23. {
  24. k=n/i/j;
  25. if(k<j) break;
  26. if(n/i%j) continue;
  27. if((i+j+k)%)continue;
  28. p=(i+j+k)/;
  29. a=p-i; b=p-j; c=p-k;
  30. if(a<||b<||c<) continue;
  31. if(a==b&&b==c) ans++;
  32. else if(a==b||b==c) ans+=;
  33. else ans+=;
  34. }
  35. }
  36. printf("%d\n",ans);
  37. return ;
  38. }

codeforces 299E Cube Problem的更多相关文章

  1. codeforces 340C Tourist Problem

    link:http://codeforces.com/problemset/problem/340/C 开始一点也没思路,赛后看别人写的代码那么短,可是不知道怎么推出来的啊! 后来明白了. 首先考虑第 ...

  2. codeforces B. Routine Problem 解题报告

    题目链接:http://codeforces.com/problemset/problem/337/B 看到这个题目,觉得特别有意思,因为有熟悉的图片(看过的一部电影).接着让我很意外的是,在纸上比划 ...

  3. Codeforces 527D Clique Problem

    http://codeforces.com/problemset/problem/527/D 题意:给出一些点的xi和wi,当|xi−xj|≥wi+wj的时候,两点间存在一条边,找出一个最大的集合,集 ...

  4. Codeforces 706C - Hard problem - [DP]

    题目链接:https://codeforces.com/problemset/problem/706/C 题意: 给出 $n$ 个字符串,对于第 $i$ 个字符串,你可以选择花费 $c_i$ 来将它整 ...

  5. Codeforces 1096D - Easy Problem - [DP]

    题目链接:http://codeforces.com/problemset/problem/1096/D 题意: 给出一个小写字母组成的字符串,如果该字符串的某个子序列为 $hard$,就代表这个字符 ...

  6. Codeforces 793C - Mice problem(几何)

    题目链接:http://codeforces.com/problemset/problem/793/C 题目大意:给你一个捕鼠器坐标,和各个老鼠的的坐标以及相应坐标的移动速度,问你是否存在一个时间点可 ...

  7. CodeForces 687A NP-Hard Problem

    Portal:http://codeforces.com/problemset/problem/687/A 二分图染色 好模板题 有SPJ 值得注意的是,因为C++的奇妙的运算机制 若在vector变 ...

  8. Codeforces Gym 100342J Problem J. Triatrip 求三元环的数量 bitset

    Problem J. Triatrip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...

  9. Codeforces Gym 100342C Problem C. Painting Cottages 转化题意

    Problem C. Painting CottagesTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...

随机推荐

  1. 不知道Java类文件结构的同学,看这篇文章就够了

    一.前言 代码编译的结果从本地机器码转变为字节码,是存储格式发展的一小步,却是编程语言发展的一大步.经过多年的发展,目前的计算机仍然只能识别0和1,但是由于近10年内虚拟机以及大量建立在虚拟机之上的程 ...

  2. c++11多线程---线程操作

    1.等待线程执行完成 join() 方法数会阻塞主线程直到目标线程调用完毕,即join会直接执行该子线程的函数体部分. 2.暂停线程(线程休眠) 使用std::this_thread::sleep_f ...

  3. imu tool使用

    安装imu tool sudo apt-get install ros-melodic-imu-tools launch文件: <!-- imu_node launch file--> & ...

  4. 通过同步上下文方式更新winform中的控件信息

    SynchronizationContext 类是一个基类,可提供不带同步的自由线程上下文. 此类实现的同步模型的目的是使公共语言运行库内部的异步/同步操作能够针对不同的异步模型采取正确的行为.此模型 ...

  5. GTX 1060 3GB 能否使用DeepFaceLab ?

    大部分人都知道跑换脸软件对电脑配置的要求比较高.所以当你想要开始玩之前都会有一个疑问:我的电脑能跑起来了么?或者我的电脑能跑那个模型? 之前写过一篇750 1G显卡如何玩deepfakes的文章.今天 ...

  6. 2、Shiro的认证

    Shiro的认证流程大体可以参考下面这幅图: 但是没有接触过shiro的同学看到上面的图片也不明白,下面我们来在代码中尝试体验Shiro的认证过程: 1.新建一个SpringBoot项目项目结构如下: ...

  7. JDK1.7安装配置环境变量+图文说明Jmeter安装

    Jmeter通常用于并发测试,本文介绍Jmeter工具的安装步骤. 工具/原料   WIN7 Jmeter安装包 JDK 一.安装JDK   1 [步骤一]安装jdk 1.下载jdk,到官网下载jdk ...

  8. ffmpeg mp4 to wmv and wmv to mp4

    //大小=>变小ffmpeg -i 1.mp4 -b:v 2M -vcodec msmpeg4 -acodec wmav2 1_mp4.wmv//大小=>变大ffmpeg -i 1.mp4 ...

  9. 中国MOOC_零基础学Java语言_第1周 计算_第1周编程题_1温度转换

    第1周编程题 依照学术诚信条款,我保证此作业是本人独立完成的. 温馨提示: 1.本次作业属于Online Judge题目,提交后由系统即时判分. 2.学生可以在作业截止时间之前不限次数提交答案,系统将 ...

  10. Java第四周总结+实验报告

    实验二 Java简单类与对象 实验目的 掌握类的定义,熟悉属性.构造函数.方法的作用,掌握用类作为类型声明变量和方法返回值: 理解类和对象的区别,掌握构造函数的使用,熟悉通过对象名引用实例的方法和属性 ...