为甚魔

B2092 开关灯

tangyiqi @ 2024-12-01 14:01:56

#include <bits/stdc++.h>
using namespace std;
struct light{
    bool light;
}a[5001];
int n,cnt = 1;
int main(){
    scanf("%d",&n);
    for(int i = 1;i<=n;i++)a[i].light = true;
    for(int i = 1;i<=n;i++){
        if(i%cnt == 0){
            if(a[i].light == true)a[i].light = false;
            else a[i].light = true;
        }
    }
    for(int i = 1;i<=n;i++)
        if(a[i].light == false)printf("%d ",i);
    return 0;
}

by dmc0702 @ 2024-12-01 20:10:56

int cnt=1;

if(i%cnt==0)

中间 cnt 没任何变化


by dmc0702 @ 2024-12-01 20:11:06

@tangyiqi


by tangyiqi @ 2024-12-02 22:02:51

@dmc0702
蟹蟹


|