From 5a893fc26752f4628c645ffc6cc1972ed994b05b Mon Sep 17 00:00:00 2001 From: ShazidMahsrafi Date: Wed, 19 Jul 2023 02:30:32 +0600 Subject: [PATCH] updated logic and code --- 230B T-primes/230B.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 230B T-primes/230B.cpp diff --git a/230B T-primes/230B.cpp b/230B T-primes/230B.cpp new file mode 100644 index 0000000..a130459 --- /dev/null +++ b/230B T-primes/230B.cpp @@ -0,0 +1,41 @@ +#include +using namespace std; +using ll = long long; + +void solve() +{ + ll N = 1e6; + vectorprime(N+1,1); + prime[0]=prime[1]=0; + for (ll i = 2; i * i <= N; ++i) + { + if (prime[i]) + { + for (ll j = i*i; j <=N; j+=i) + prime[j]=0; + } + } + ll n; + cin>>n; + while(n--) + { + ll x; + cin>>x; + ll r= sqrt(x); + if(r*r!=x) cout<<"NO"<> TC; + // cin.ignore(); + while (TC--) + solve(); +} \ No newline at end of file