BNUOJ 19297 Code Refactoring
Code Refactoring
64-bit integer IO format: %lld Java class name: Main
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 #x: K = A * B = C * D", where A, B, C and D are different positive integers larger than 1. A solution will always exist.
| Sample Input | Sample Output |
3 |
Case #1: 120 = 12 * 10 = 6 * 20 |
#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的更多相关文章
- 探究重构代码(Code refactoring)
Code refactoring 是什么 在不改变软件的外部行为的条件下,通过修改代码改变软件内部结构,将效率低下和过于复杂的代码转换为更高效.更简单和更简单的代码. 怎样执行Code refacto ...
- taiyi_interview(Introduction To Database Refactoring)
Introduction To Database Refactoring 原文链接:by Scott W. Ambler:http://www.tdan.com/view-articles/5010/ ...
- Code Complete阅读笔记(二)
2015-03-06 328 Unusual Data Types ——You can carry this technique to extremes,putting all the ...
- 探究代码审查(Code review)
Code review 是什么 对软件源代码的系统性检查,查找软件源代码质量,结构,漏洞等问题. PS:Code review ≍ Code inspections ≥ Code walkthrou ...
- jQuery WipeTouch
有时,当你只想为触屏划动添加事件时,很多人可能会想到,Jquery mobile,但就这么个功能就把人家这么高大上的东西引用进来就有点大才小用了,WipeTouch是国外某程序员写的针对触屏划动的jq ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- Domain Driven Design and Development In Practice--转载
原文地址:http://www.infoq.com/articles/ddd-in-practice Background Domain Driven Design (DDD) is about ma ...
- 【转】Git代码提交最佳实践
GIT Commit Good Practice The following document is based on experience doing code development, bug ...
- Recommended add-ons/plugins for Microsoft Visual Studio [closed]
SmartPaster - (FREE) Copy/Paste code generator for strings AnkhSvn - (FREE) SVN Source Control Integ ...
随机推荐
- C# 连接 Oracle,读取Blob字段数据,存到文件中去,包括pdf等等
代码如下,记得引入Oracle的dll using System; using System.Collections.Generic; using System.ComponentModel; usi ...
- 图片压缩(pc端和移动端都适用)
最近在做移动端遇到了一个问题就是: 手机拍照后,图片过大如果上传到服务器务必会浪费带宽,最重要的是流量啊 别慌,好事儿来了,务必就会有人去研究研究图片的压缩: 鄙人结合前人的经验,结合自己实战,总结出 ...
- uvm_factory——我们的工厂(二)
上节我们说到uvm_object_registry #(T),uvm_object_reistry 又继承自uvm_object_wrapper,所以首先,让我们先看看它爹是啥样子的: //----- ...
- php关于精准计算的模块 BCMath
Php: BCMath bc是Binary Calculator的缩写.bc*函数的参数都是操作数加上一个可选的 [int scale],比如string bcadd(string $left_ope ...
- C# 语言 类
++++String类+++++黑色小扳手 - 属性紫色立方体 - 方法 ***字符串.Length - 字符串长度,返回int类型 字符串.TrimStart() - 去掉前空格字符串.TrimEn ...
- LINUX提高openfire并发数(网上收集)
谷歌博客地址:http://tsaiquinn.blogspot.com/2014/10/linuxopenfire.html 影响连接数的元素包含三种:1)Linux的系统参数2)进程自身可以创建的 ...
- 一个具体的例子学习Java volatile关键字
相信大多数Java程序员都学习过volatile这个关键字的用法.百度百科上对volatile的定义: volatile是一个类型修饰符(type specifier),被设计用来修饰被不同线程访问和 ...
- chm文件帮助功能全解
在winform中点击某个按钮弹出关于这个窗体的功能的具体解释文档方法如下: 第一步,使用chm编译工具修改chm每个文档的url 修改完成后保存确认能否打开, 如果不能就使用这个软件的转换功能把ch ...
- 字符串赋值方式理解 sizeof 和strlen的一些区别
#include<stdio.h>#include<string.h> int main(){ int a,i=0; char ch[10000]; while(scanf( ...
- linux中复制文件夹的所有文件到指定目录
这里我们的需求是需要将一个文件夹中的所有文件都复制到另一个文件夹中,而不是将一个文件夹复制到另外一个文件夹中. //这里需要使用到-R参数,表示递归处理,将指定目录下的所有文件与子目录一并处理//一开 ...