UESTC 1246 Demolition X3

Source: Internet
Author: User
Tags define local

Using inductive analysis, we can know that the dead loop is only 4.

Analyze the complexity, if n is large and not a prime number, the sum factor (n) ≥2+N/2≈N/2 can be known according to the basic inequality.

The complexity is O (t*logn*sqrt (N)), the upper bound is relatively loose. If you use Pollard_rho again to open a square estimate constant is also similar.

#include <bits/stdc++.h>using namespaceStd;typedefLong Longll;intDecompose (intXBOOL&is_pm) {    intRe =0;  for(inti =2; I*i <= x; i++){         while(x% i = =0) {Re+ = i; X/=i; }} is_pm= !re; if(X >1) {Re+=x; }    returnre;}//#define LOCALintMain () {#ifdef LOCAL freopen ("In.txt","R", stdin);#endif    intx, y; BOOLis_pm;  while(~SCANF ("%d", &x)) {        if(x = =4) puts ("-1"); Else {             while(true) {y=decompose (x, is_pm); if(IS_PM) Break; X=y; } printf ("%d\n", x); }    }    return 0;}

UESTC 1246 Demolition X3

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.