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. React Native开发时devices offline和手机不能晃动的处理

    1. adb device 显示 devices offline 可能重启adb server: $ adb kill-server $ adb start-server 2. 华为等手机不能 晃动显 ...

  2. vue2 mint-ui loadmore(下拉刷新,上拉更多)

    <template> <div class="page-loadmore"> <h1 class="page-title"> ...

  3. java.lang.ClassCastException android.widget.RelativeLayout LayoutParams 异常

    1.在xml布局文件如下所示: <RelativeLayout android:layout_width="match_parent" android:layout_heig ...

  4. JavaScript数据格式验证探讨

    1.需求 修改某个文本框数据,要求对修改后的格式做验证(必须是数字). 注:实际需求比上述复杂,为了说明问题,这里特意简化了需求(如:对修改后数据依赖条件的判断,数据入库等). 2.关于NaN的探讨( ...

  5. Android程序初体验

    第一个程序的实现的最终功能是: 点击"正确"或者"错误"会得到一个是否正确的提示. 直接上效果图.     此次涉及代码编写的文件有4个: package co ...

  6. Longest Increasing Subsequence的两种算法

    问题描述:给出一个序列a1,a2,a3,a4,a5,a6,a7-.an,求它的一个子序列(设为s1,s2,-sn),使得这个子序列满足这样的性质,s1<s2<s3<-<sn并且 ...

  7. 面试题--JAVA中静态块、静态变量加载顺序

    最后给大家一道面试题练练手,要求写出其结果(笔试) public class StaticTest { public static int k = 0; public static StaticTes ...

  8. Jsoup获取全国地区数据(省市县镇村)(续) 纯干货分享

    前几天给大家分享了一下,怎么样通过jsoup来从国家统计局官网获取全国省市县镇村的数据.错过的朋友请点击这里.上文说到抓取到数据以后,我们怎么转换成我们想要格式呢?哈哈,解析方式可能很简单,但是有一点 ...

  9. 洛谷 P2483 [SDOI2010]魔法猪学院

    题目描述 iPig在假期来到了传说中的魔法猪学院,开始为期两个月的魔法猪训练.经过了一周理论知识和一周基本魔法的学习之后,iPig对猪世界的世界本原有了很多的了解:众所周知,世界是由元素构成的:元素与 ...

  10. mvc工作总结

    MVC的页面跳转方式(放在一般类): filterContext.Result = new RedirectResult("controller/action"); filterC ...