Code Refactoring

Time Limit: 3000ms
Memory Limit: 131072KB
 
This problem will be judged on UVA. Original ID: 10879
64-bit integer IO format: %lld      Java class name: Main
 
 
Problem B
Code Refactoring
Time Limit: 2 seconds

"Harry, my dream is a code waiting to be
broken. Break the code, solve the crime."


Agent Cooper

Several algorithms in modern cryptography are based on the fact that factoring large numbers is difficult. Alicia and Bobby know this, so they have decided to design their own encryption scheme based on factoring. Their algorithm depends on a secret code, K, that Alicia sends to Bobby before sending him an encrypted message. After listening carefully to Alicia's description, Yvette says, "But if I can intercept K and factor it into two positive integers, A and B, I would break your encryption scheme! And theK values you use are at most 10,000,000. Hey, this is so easy; I can even factor it twice, into two different pairs of integers!"

Input
The first line of input gives the number of cases, N (at most 25000). N test cases follow. Each one contains the code, K, on a line by itself.

Output
For each test case, output one line containing "Case #xK = A * B = C * D", where ABC and D are different positive integers larger than 1. A solution will always exist.

Sample Input Sample Output
3
120
210
10000000
Case #1: 120 = 12 * 10 = 6 * 20
Case #2: 210 = 7 * 30 = 70 * 3
Case #3: 10000000 = 10 * 1000000 = 100 * 100000
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#define LL long long
using namespace std;
int main(){
int kase,x,i,j,k = ;
int a[],b[];
scanf("%d",&kase);
while(kase--){
scanf("%d",&x);
for(j = ,i = ; i < x && j < ; i++){
if(x%i == ){
a[j] = i;
b[j++] = x/i;
}
}
printf("Case #%d: %d = %d * %d = %d * %d\n",k++,x,a[],b[],a[],b[]);
}
return ;
}

最新文章

  1. WebService 概念和工作原理(一)
  2. FBI阅人术——用最短的时间了解一个人
  3. LL(1)文法
  4. https 与http 的坑
  5. 使用diff制作补丁
  6. 浅谈C/C++中的顺序点和副作用
  7. JVM加载class文件的原理
  8. cc.RepeatForever和cc.Spawn冲突
  9. poj 2431 Expedition 贪心
  10. 【前端学习】javascript面向对象编程(继承和复用)
  11. NET中级课--文件,流,序列化3
  12. linux—select具体解释
  13. JQuery 网页瞄点
  14. springCloud com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect
  15. BZOJ4378[POI2015]Logistyka——树状数组
  16. php的pear编程: phpDocumentor的使用?
  17. Apache Hadoop Operations at Scale
  18. 洛谷 P1123 取数游戏
  19. Hbase 管理页面
  20. Luogu 3373 - 【模板】线段树 2 - [加乘线段树]

热门文章

  1. Linux-软件安装(一) —— jdk/tomact 安装(普通安装)
  2. CSS3 基本要素概览
  3. iOS 自适应高度,改变字体颜色
  4. C语言中的fprintf函数详解
  5. IOS小技巧整理
  6. 【数据库-Azure SQL Database】JDBC 如何连接 SQL Azure 数据库
  7. MSSQL复制表
  8. SQL server 数据库基础语句 子查询 基础函数
  9. 在前台引用JSON对象
  10. COGS 133. [USACO Mar08] 牛跑步