3 条题解

  • 1
    @ 2024-9-22 15:21:10
    #include<bits/stdc++.h>
    #define MAXN 5001 
    using namespace std;
    int a[MAXN];
    int main()
    {
        int n,m;
        memset(a,0,sizeof(a));
        //作用是把数组a清零
        cin>>n>>m;
        for(int i=1;i<=n;++i){
        	for(int j=1;j<=m;++j){
        		if(j%i==0){
        			a[j]=!a[j];	
    				//给a[j]赋与其相反的真假值,例如,如果a[j] = 5, 那这个赋值后a[j] = 0如果a[j]=0,赋值语句后a[j]=1	
    			}
    		}
    	}
    	if(a[1]){
    			cout<<1;
    		}
    	for(int i=2;i<=n;++i){
    		if(a[i]){
    			cout<<","<<i;
    		}
    	}
    	cout<<endl;
        return 0;
    }

    信息

    ID
    501
    时间
    1000ms
    内存
    128MiB
    难度
    8
    标签
    递交数
    43
    已通过
    7
    上传者