导读:c++编程T-primes number c++编程T-primes numberDescriptionWe know that prime numbers are positive integers that have exactly two distinct positive divisors.Similarly,we‘ll call a positive integer...
c++编程T-primes number
c++编程T-primes number
Description
We know that prime numbers are positive integers that have exactly two distinct positive divisors.
Similarly,we'll call a positive integer t Т-prime,if t has exactly three distinct positive divisors.
You are given an array of n positive integers.For each of them determine whether it is Т-prime or not.
Input
The first line contains a single positive integer,n (1 ≤ n ≤ 10000),showing how many numbers are in the array.
The next line contains n space-separated integers xi (1 ≤ xi ≤ 10^12).
Output
Print one line:The number of T-primes number
Time Limit:1sec!
遗忘的大海
1年前他留下的回答
已收到1个回答
牙牙2000
网友
该名网友总共回答了20个问题,此问答他的回答如下:采纳率:85%
//#include "stdafx.h"//vc++6.0加上这一行.
#include "stdio.h"
#include "stdlib.h"
bool T_prime(__int64 n){
x09 __int64 i,x;
x09 if(n
1年前他留下的回答
追问
8
遗忘的大海
貌似不对啊~~~~~~
牙牙2000
//#include "stdafx.h"//vc++6.0加上这一行.
#include "stdio.h"
#include "stdlib.h"
bool T_prime(__int64 n){
__int64 i,x;
if(n<4)x09return false;
for(i=2;(x=i*i)
if(n%i==0) return false;
if(x==n) return true;
else return false;
}
void main(void){
int n,i;
__int64 *xi;
while(1){
printf("Type n(1<=n<=10000)...nn=");
scanf("%d",&n);
if(n>0 && n<10001) break;
printf("Error, redo: ");
}
if((xi=(__int64 *)malloc(n*sizeof(__int64)))==NULL){
printf("Application memory failure...n");
exit(0);
}
for(i=0;i
printf("======================================n");
for(i=0;i
if(T_prime(xi[i]))
printf("%I64d ",xi[i]);
free(xi);
printf("n");
}
说出不对来……
遗忘的大海
没错。。谢啦
以上就是小编为大家介绍的c++编程T-primes number 的全部内容,如果大家还对相关的内容感兴趣,请持续关注宽屏壁纸网!
标签:
内容声明:网站所展示的内容均由第三方用户投稿提供,内容的真实性、准确性和合法性均由发布用户负责。诚智拓展网对此不承担任何相关连带责任。诚智拓展网遵循相关法律法规严格审核相关关内容,如您发现页面有任何违法或侵权信息,欢迎向网站举报并提供有效线索,我们将认真核查、及时处理。感谢您的参与和支持!