This problem is a math problem (also written below), so after careful study, it is found that after N rounds, only the lights of perfect square numbers less than N can be turned on. So it's easy to do next:
#include<bits/stdc++.h> using namespace std; int n; int main(){ scanf("%d",&n); for(int i=1;i<=sqrt(n);i++) printf("%d ",i*i); puts("");return 0; }