Whether hdu 3826 number theory n can be filled with a factor is a very good question for the number of integers.

Source: Internet
Author: User

Squarefree number
Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 1404 Accepted Submission (s): 373


Problem Description
In mathematics, a squarefree number is one which is divisible by no perfect squares, limit T 1. for example, 10 is square-free but 18 is not, as it is divisible by 9 = 3 ^ 2. now you need to determine whether an integer is squarefree or not.
 

Input
The first line contains an integer T indicating the number of test cases.
For each test case, there is a single line contains an integer N.

Technical Specification

1. 1 <= T <= 20
2. 2 <= N <= 10 ^ 18
 

Output
For each test case, output the case number first. Then output "Yes" if N is squarefree, "No" otherwise.
 

Sample Input
2
30
75
 

Sample Output
Case 1: Yes
Case 2: No
 

Author
Hanshuai
 
Question:
Can n be rounded out by the number of shards containing a factor?
Can output no, cannot output yes

[Cpp] view plaincopy
/* If a number n can be divisible by the square of a number, the number must be rounded out by the square of a prime number.
If an even number is exceeded by the square of an even number, because the even number = 2 * x must contain the prime number 2, it can be rounded out by the square of quality 2.
If a number can be divisible by an odd number of squares = a prime number x, it can be rounded out by the Quality square.
The data in this question is large and can be processed as follows:
If n> 10 ^ 6
1. Find all the prime numbers in 10 ^ 6 to see if n can be divided into the square of these prime numbers. If No can be output
2. the maximum data size is 10 ^ 18. If there is at most one number x, x is used to integer n because n * n is greater than 10 ^ 18.
Therefore, if it is available to its users, No is output.
 
Extended thinking:
The number of workers can be divided into the square of a certain Prime Number * some prime numbers
*/
# Include <stdio. h>
# Include <math. h>
# Include <string. h>
Int vis [1000000 + 5];
Int prime [79000];
Int cnt [79000 + 5];
Int c;
Void get_prime ()
{
Int I, j, n, m;
C = 0;
N = 1000000;
M = (int) sqrt (n + 0.5 );
Memset (vis, 0, sizeof (vis ));
For (I = 2; I <= m; I ++)
If (! Vis [I])
{
For (j = I * I; j <= n; j + = I)
Vis [j] = 1;
}
For (I = 2; I <= n; I ++) if (! Vis [I])
Prime [c ++] = I;
}
# Include <stdio. h>
Int main ()
{
Int I, j, cas, flag, k;
_ Int64 n, m;
Double num;
Get_prime ();
Scanf ("% d", & cas );
For (k = 1; k <= cas; k ++)
{
Scanf ("% I64d", & n );
Memset (cnt, 0, sizeof (cnt); flag = 0;
For (j = 0; j <c; j ++)
{
M = n;
While (m % prime [j] = 0)
{
M/= prime [j];
Cnt [j] ++;
If (cnt [j]> = 2) {flag = 1; break ;}
}
If (flag) break;
}
If (n> 1000000)
{
Num = sqrt (double) n); // double must be added here; otherwise, the compilation is incorrect.
If (floor (num + 0.5) = num) flag = 1;
} Www.2cto.com
If (flag) printf ("Case % d: No \ n", k );
Else printf ("Case % d: Yes \ n", k );
}
Return 0;
}

 


Author: hnust_xiehonghao

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.