为什么错了 Why is it wrong! Help me!
  • 板块B2092 开关灯
  • 楼主shenliyan
  • 当前回复7
  • 已保存回复7
  • 发布时间2025/2/5 10:17
  • 上次更新2025/2/5 14:34:55
查看原帖
为什么错了 Why is it wrong! Help me!
1643406
shenliyan楼主2025/2/5 10:17
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int a[5001];
int main(){
    int n,m,z=1;
    cin>>n>>m;
    memset(a,0,sizeof(a));
    for(int i=1;i<=m;++i)
      for(int j=1;j<=n;++j)
      if(j%i==0) a[j]=!a[j];
      for(int i=1;i<=n;++i)
      if(a[i])
      {
          if(z) z=0;
          else printf(" ");
          printf("%d",i);
      }
      printf("\n");
    return 0;
  }

样例都过,但是全错

2025/2/5 10:17
加载中...