"Small Method-The simplest" C-factorization factor

Source: Internet
Author: User

C-factorization factor crawling in Process ... crawling Failed time Limit: 2000ms      Memory Limit: 10240kb     64bit IO Format: % LLD &%llu

Submit Status

Description

Suppose X is a positive integer whose value is not more than 65535 (that is, 1< x < =65535), write a program that

Decomposes x into multiples of a number of primes.

Input

The first line of the input contains a positive integer k (1<=k<=10), which indicates the number of test cases followed by the K line,

Each row corresponds to a test example that contains a positive integer x.

Output

Each test example corresponds to a row of output, the prime number of the output of the product expression, the prime number from small to large array,

The multiplication is represented by "*" Between two primes.

Sample Input

  2  9828

Sample Output

    2*2*3*3*3*7*13
Note: Has been overrun, almost collapsed, can optimize all the thought, but after all, is slag, finally Baidu
Although do not understand, but the magic of the discovery is very useful,,, and read a few times learned, I-- ,
Genius Ah, must keep!!
#include <stdio.h>intMain () {intN,i,j,a; scanf ("%d",&N);  while(n--) {scanf ("%d",&a); if(a==1) printf ("1");  for(i=2; i<=a;i++)        {            if(a%i==0) {printf ("%d", i); if(i!=a) printf ("*"); A/=i; I--; }        }        if(a!=1) printf ("%d", a); printf ("\ n"); }}

"Small Method-The simplest" C-factorization factor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.