Bholu the Pandit on this New Year wanted to divide his Cuboidal Packaging block into cubes. But he loves uniformity so he asks you to divide it such a way that all the cubes are of same size and volume of individual cube is as large as possible.

Note: He will utilize whole volume i.e volume of cuboid before dividing is same as sum of volume of all the cubes.

Input
The first input line contains an integer T, the number of testcases. Each testcase consist of single line which consist of 3 space separated integers a, b & c representing length, breadth and height of the Cuboidal block.

Output
For each testcase you need to output 2 space separated integers, the length of side of the cube and the number of cubes which could be formed out of this cuboidal packaging block. As the number of cubes which could be made could be a large number so just output the answer modulus 109+7 (1000000007).

Constraints
1 ≤ T ≤ 1000
1 ≤ a,b,c ≤ 109

SAMPLE INPUT
 
 
2
2 4 6
1 2 3
SAMPLE OUTPUT
 
 
2 6
1 6
 
Explanation

In the 1st testcase a=2, b=4 & c=6. So length of the side of the cube would be 2 and the number of cubes which would be formed would be 6. In the 2nd testcase a=1, b=2 & c=3. So length of the side of the cube would be 1 and the number of cubes which would be formed would be 6.

Time Limit:1.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB
Marking Scheme:Marks are awarded when all the testcases pass.
Allowed Languages:Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), TypeScript, Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, Visual Basic

Approach # 1:

/*
// Sample code to perform I/O: #include <iostream> using namespace std; int main() {
int num;
cin >> num; // Reading input from STDIN
cout << "Input number is " << num << endl; // Writing output to STDOUT
} // Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/ // Write your code here
#include<iostream>
#include<algorithm>
const int mod = 1e9 + 7; using namespace std; long long gcd(long long x, long long y) {
if (y == 0)
return x;
else return gcd(y, x%y);
} int main() {
int n;
long long l, w, h;
long long ans;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> l >> w >> h;
long long c = gcd(gcd(l, w), h);
l /= c;
w /= c;
h /= c;
ans = (((l * w) % mod) * h) % mod;
cout << c << ' ' << ans << endl;
} return 0;
}

  

Analysis:

From this problem I learned how to deal with the three numbers problem. And we shuold use long long.

Blocks to Cubes的更多相关文章

  1. Intel® Threading Building Blocks (Intel® TBB) Developer Guide 中文 Parallelizing Data Flow and Dependence Graphs并行化data flow和依赖图

    https://www.threadingbuildingblocks.org/docs/help/index.htm Parallelizing Data Flow and Dependency G ...

  2. POJ 1052 Plato's Blocks

      Plato's Blocks Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 734   Accepted: 296 De ...

  3. Codeforces Round #356 (Div. 2) D. Bear and Tower of Cubes dfs

    D. Bear and Tower of Cubes 题目连接: http://www.codeforces.com/contest/680/problem/D Description Limak i ...

  4. codeforces 680D D. Bear and Tower of Cubes(dfs+贪心)

    题目链接: D. Bear and Tower of Cubes time limit per test 2 seconds memory limit per test 256 megabytes i ...

  5. Codeforces Round #295 D. Cubes [贪心 set map]

    传送门 D. Cubes time limit per test 3 seconds memory limit per test 256 megabytes input standard input ...

  6. 从Script到Code Blocks、Code Behind到MVC、MVP、MVVM

    刚过去的周五(3-14)例行地主持了技术会议,主题正好是<UI层的设计模式——从Script.Code Behind到MVC.MVP.MVVM>,是前一天晚上才定的,中午花了半小时准备了下 ...

  7. 【POJ-1390】Blocks 区间DP

    Blocks Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 5252   Accepted: 2165 Descriptio ...

  8. 开发该选择Blocks还是Delegates

    前文:网络上找了很多关于delegation和block的使用场景,发现没有很满意的解释,后来无意中在stablekernel找到了这篇文章,文中作者不仅仅是给出了解决方案,更值得我们深思的是作者独特 ...

  9. 水泡动画模拟(Marching Cubes)

    Marching Cubes算法是三维离散数据场中提取等值面的经典算法,其主要应用于医学领域的可视化场景,例如CT扫描和MRI扫描的3D重建等. 算法主要的思想是在三维离散数据场中通过线性插值来逼近等 ...

随机推荐

  1. SPI子系统分析之一:框架

    内核版本:3.9.5 SPI子系统概述: 一个SPI主控制器对应一条SPI总线,当然在系统中有唯一的总线编号. SPI总线上有两类设备: 其一是主控端,通常作为SOC系统的一个子模块出现,很多嵌入式M ...

  2. 封装baseControl

    package com.huawei.base; import java.io.IOException;import java.io.OutputStream;import java.io.Print ...

  3. Linux实战教学笔记53:开源虚拟化KVM(一)搭建部署与概述

    一,KVM概述 1.1 虚拟化概述 在计算机技术中,虚拟化意味着创建设备或资源的虚拟版本,如服务器,存储设备,网络或者操作系统等等 [x] 虚拟化技术分类: 系统虚拟化(我们主要讨论的反向) 存储虚拟 ...

  4. TCP与UDP与HTTP协议

    http:是用于www浏览的一个协议.tcp:是机器之间建立连接用的到的一个协议. 1.TCP/IP是个协议组,可分为三个层次:网络层.传输层和应用层.在网络层有IP协议.ICMP协议.ARP协议.R ...

  5. DecoratorPattern(23种设计模式之一)

    参考书籍:设计模式-可复用面向对象软件基础(黑皮书) 书中写到,装饰者模式的意图是动态的给对象添加一些额外的职责.就增加功能来说,Decorator模式相比生成子类更为灵活.装饰者模式的另一个别名是包 ...

  6. Python监控日志程序-乾颐堂

    一个简易的日志监控的脚本,功能如下:1.windows环境2.当匹配日志关键字时会发出声音,匹配的关键字不同,播放的声音不同3.能做到实时响应 注意:是在win环境下哦 直接上代码吧 1 2 3 4 ...

  7. java 中toString()方法详解

    1.toString()方法 Object类具有一个toString()方法,你创建的每个类都会继承该方法.它返回对象的一个String表示,并且对于调试非常有帮助.然而对于默认的toString() ...

  8. Smarty的循环

    (1)section.sectionelse功能多,参数多.或许不是太实用.是smarty用来做循环操作的函数之一.(2)了解基本属性name和loop <section name=articl ...

  9. Linux Mint 17使用配置

    => 调亮度: 方法一: 每次开机或注销登录之后需要重新设置 > /sys/class/backlight/intel_backlight/brightness #根据自己需要调值,如20 ...

  10. 基于maven从头搭建springMVC框架

    0.准备工作 首先将eclipse和需要的插件准备好,例如maven插件,spring IDE插件. 1.建立maven下的webapp项目 1.新建一个maven项目,类型为webapp,如下图 2 ...