Facebook
From TOMMY, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 161
  1. #include<bits/stdc++.h>
  2. #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  3. #define file freopen("CLOPRIME.inp","r",stdin);freopen("CLOPRIME.out","w",stdout);
  4. using namespace std;
  5. int main(){
  6.  file;
  7.  bool ktra[500005];
  8.  memset(ktra,true,sizeof(ktra));
  9.  ktra[0]=ktra[1]=false;
  10.  for(int i=2;i*i<=500005;i++)
  11.   if (ktra[i])
  12.    for (int j=i*i;j<=500005;j+=i)
  13.     ktra[j]=false;
  14.  int n,x;
  15.  cin>>n;
  16.  for (int i=1;i<=n;i++){
  17.   cin>>x;
  18.   while (!ktra[x])
  19.    x--;
  20.   cout<<x<<endl;
  21.  }
  22.  return 0;
  23. }

Replies to Untitled rss

Title Name Language When
cloprime trần bá nguyên text 1 Month ago.