1 条题解

  • 0
    @ 2024-5-17 20:50:39

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n,m,cnt=0,is_first=1;
    	cin>>n>>m;
    	//灯初始开启
    	//找关闭的灯 
    	for(int i=1;i<=n;i++)
    	{
    		cnt=0;
    		for(int j=1;j<=m;j++)
    		{
    			if(i%j==0)
    			{
    				cnt++;
    			}
    		}
    		if(cnt%2!=0)
    		{
    			if(is_first)
    			{
    				is_first=0;
    			}
    			else
    			{
    				cout<<",";
    			}
    			cout<<i;
    		}
    	} 
    	return 0;
    }
    
    
    • 1

    信息

    ID
    5682
    时间
    1000ms
    内存
    128MiB
    难度
    6
    标签
    递交数
    29
    已通过
    12
    上传者