1 条题解

  • 0
    @ 2025-2-14 20:50:08

    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
    440
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者