Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- int ktnt(long long a){
- if(a==2){
- return 1;
- }
- if(a<2||a%2==0){
- return 0;
- }
- for(int i=3;i<=sqrt(a);i+=2){
- if(a%i==0){
- return i;
- break;
- }
- }
- return 1;
- }
- int main(){
- int t;
- cin >> t;
- while(t--){
- long long n,i;
- cin >> n;
- cout << 1 << " ";
- for(i = 2; i<=n; i++){
- if(i%2==0){
- cout << 2 << " ";
- }else{
- if(ktnt(i)==1){
- cout << i << " ";
- }else{
- cout << ktnt(i) << " ";
- }
- }
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement