Project Euler largest prime factor&largest palindrome product

Source: Internet
Author: User

(3rd question = =)
Original question:
The prime factors of 13195 is 5, 7, and 29.
What is the largest prime factor of the number 600851475143?
Effect:
Ask you 600851475143 the maximum factor is how much.
(Fourth question = =)
Original question:
A palindromic number reads the same both ways. The largest palindrome made from the product of both 2-digit numbers is 9009 = 91x99.
Find the largest palindrome made from the product of the 3-digit numbers.
Effect:
Let you find two 3-digit multiply results maximum palindrome number.

Calculation code:

#include <bits/stdc++.h>//3 using namespace std;
    int main () {Ios::sync_with_stdio (false);
    Long Long n,ans=2;
    cin>>n;
    Long Long fac= (long Long) sqrt (n*1.0+0.5) +1;
    Long Long i=2;
            while (i<=fac&&n>1) {while (n%i==0) {n/=i;
        Ans=max (Ans,i);
    } i++;
    } cout<<ans<<endl;
return 0;

} #include <bits/stdc++.h>//4 using namespace std;
    BOOL Ispal (string s) {string Rev;
    Rev.assign (S.rbegin (), S.rend ());
    if (S==rev) return true;
return false;
    } int main () {Ios::sync_with_stdio (false);
    StringStream SS;
    string S;
    int ans=0;
            for (int i=999;i>=100;i--) {for (int j=999;j>=100;j--) {ss.clear ();
            ss<< (I*J);
            ss>>s;
            if (Ispal (s)) {Ans=max (I*j,ans);
    }}} cout<<ans<<endl; RetUrn 0;

 }

Answer:
This is the first time the topic of Web-based project EULA, look at math problems, exercise brain-This problem is very simple, violence to find out. = =

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.