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

BNUOJ 19297 Code Refactoring的更多相关文章

  1. 探究重构代码(Code refactoring)

    Code refactoring 是什么 在不改变软件的外部行为的条件下,通过修改代码改变软件内部结构,将效率低下和过于复杂的代码转换为更高效.更简单和更简单的代码. 怎样执行Code refacto ...

  2. taiyi_interview(Introduction To Database Refactoring)

    Introduction To Database Refactoring 原文链接:by Scott W. Ambler:http://www.tdan.com/view-articles/5010/ ...

  3. Code Complete阅读笔记(二)

    2015-03-06   328   Unusual Data Types    ——You can carry this technique to extremes,putting all the ...

  4. 探究代码审查(Code review)

    Code review 是什么 对软件源代码的系统性检查,查找软件源代码质量,结构,漏洞等问题. PS:Code review  ≍ Code inspections ≥ Code walkthrou ...

  5. jQuery WipeTouch

    有时,当你只想为触屏划动添加事件时,很多人可能会想到,Jquery mobile,但就这么个功能就把人家这么高大上的东西引用进来就有点大才小用了,WipeTouch是国外某程序员写的针对触屏划动的jq ...

  6. UVA题目分类

    题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...

  7. Domain Driven Design and Development In Practice--转载

    原文地址:http://www.infoq.com/articles/ddd-in-practice Background Domain Driven Design (DDD) is about ma ...

  8. 【转】Git代码提交最佳实践

      GIT Commit Good Practice The following document is based on experience doing code development, bug ...

  9. Recommended add-ons/plugins for Microsoft Visual Studio [closed]

    SmartPaster - (FREE) Copy/Paste code generator for strings AnkhSvn - (FREE) SVN Source Control Integ ...

随机推荐

  1. Asp.Net实现记录历史访问人数和当前在线人数

    ************************************在Global.asax中如下************************ <%@ Import Namespace= ...

  2. (AOP)理解

    AOP的全称: Aspact  Oriented  Programming AOP的目标(作用):让我们可以“专心做事”  日志记录,事务处理,异常捕获,缓存操作. AOP原理 将复杂的需求分解出不同 ...

  3. java 利用c3p0管理数据库连接池

    数据库连接池类,用于获取数据库连接.利用单例模式保证所有的连接都只通过一个连接池管理. package com.mousewheel.dbcon; import java.io.InputStream ...

  4. php调用c# webservice方法

    第一次用,通过,还没深入了解. 首先在php.ini中启用extension=php_soap.dll,重启apache. $Client=new SoapClient("url?wsdl& ...

  5. 在每天黄金时刻将数据库中数据获取包装成Excel表

    过程: 1.由Timer对象实现安排指定的任务在指定的时间进行重复的固定的延迟操作 a.设定时间间隔24小时:PERIOD_DAY = 24 * 60 * 60 * 100; b.指定每天执行操作的时 ...

  6. Java文件操作系列[3]——使用jacob操作word文档

    Java对word文档的操作需要通过第三方组件实现,例如jacob.iText.POI和java2word等.jacob组件的功能最强大,可以操作word,Excel等格式的文件.该组件调用的的是操作 ...

  7. 修改完linux bashrc文件之后,如何不重启系统使其生效

    修改完后,输入如下命令即可 ##@##:~/    source ~/.bashrc 之后bashrc文件就可以使用! 注: 使用ssh登陆shell的时候,系统不会自动调用.bashrc文件, 只是 ...

  8. SQL2005中使用backup、restore来备份和恢复数据库

    在SQL2005数据库中利用SQL语句进行数据备份与还原: 备份backup:backup database 数据库名称 tO disk = 备份路径例:BACKUP DATABASE test TO ...

  9. Docker镜像的目录存储讲解

    我们成功安装完docker后,执行命令行sudo docker run hello-world, 如果是第一次执行,则会从远程拉取hello-world的镜像到本地,然后运行,显示hello worl ...

  10. saltstack-day1

    一.远程执行命令 1.指定一个ipv4地址或者一个子网 salt -S 172.16.7.19 test.ping salt -S test.ping 2. 正则表达式 salt -E "j ...