noip2012 mass factor decomposition (enumeration)

Source: Internet
Author: User

P2067 [NOIP2012P1] mass factor decomposition time: 1000ms/Space: 131072kib/java class name: Main background NOIP2012
describes a known positive integer n is the product of two different prime numbers, trying to find the larger prime number.
Input format input has only one row and contains a positive integer n.
output format output has only one row, containing a positive integer p, which is the larger prime number.
Test Sample 1 input output 7 Memo "data range"
For 60% of data 6≤n≤1000
For the 100% data 6≤n≤2*10^9 code:

#include <cstdio>
using namespace std;

int main ()
{
  int i,j,k,n;
  scanf ("%d", &n);
  for (i=2;i<n;i++)
    if (n%i==0) {printf ("%d\n", n/i);
  return 0;
}




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.