NOI 1.5 43: Mass factor decomposition

Source: Internet
Author: User

Describe

A known positive integer n is the product of two different prime numbers, trying to find the larger prime number.

Input
The input has only one row and contains a positive integer n.

For 60% of data, 6≤n≤1000.
For 100% of data, 6≤n≤2*10^9.
Output
The output has only one row and contains a positive integer p, which is the larger prime number.
Sample input
21st
Sample output
7
Source
The
first problem of the popularization group of NOIP2012
      • Fayi
#include <bits/stdc++.h>using namespacestd;intN;intMain () {scanf ("%d",&n); for(intI=2; i<n;i++){if(n%i==0) {printf ("%d", n/i); Break;return 0;}}return 0; }

  • Law II
    #include <iostream>#include<cmath>using namespacestd;intMain () {intn,t; CIN>>N; T=sqrt (n);  for(intI=2; i<=t;i++)    {        if(n%i==0) {cout<<n/i; return 0; }     }}

NOI 1.5 43: Mass factor decomposition

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.