2 solutions

  • 3
    @ 2024-1-22 10:33:14
    #include<bits/stdc++.h>
    using namespace std;
    int n;
    bool a[5005]={};
    int m;
    int main(){
    	cin>>n>>m;
    	for(int i=1;i<=m;i++){
    		for(int j=1;j<=n;j++){
    			if(j%i==0) a[j]=!a[j];
    		}
    	}
    	bool vst=true;
    	for(int i=1;i<=n;i++){
    		if(a[i]){
    			if(vst) vst=false,cout<<i;
    			else cout<<','<<i;
    		}
    	}
    	return 0;
    }
    
    • 0
      @ 2023-12-17 21:34:09
      #include <bits/stdc++.h>
      using namespace std;
      int main(){
          bool a[5005] = {};
          int n, m;
          cin >> n >> m;
          for(int i = 2; i <= m; ++i){
              for(int j = 1; j <= n; ++j){
                  if (j % i == 0){
                      if(a[j])
                          a[j] = false;
                      else
                          a[j] = true;
                  }
              }
          }
          bool isFirst = true;
          for(int j = 1; j <= n; ++j){
              if(a[j] == false){
                  if (isFirst)
                      isFirst = false;
                  else
                      cout << ',';
                  cout << j;
              }
          }
          return 0;
      }
      
      
      • 1

      Information

      ID
      595
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      4
      Tags
      # Submissions
      47
      Accepted
      22
      Uploaded By