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