捞,subtask3 #9WA了,其他都A了,悬1关。
  • 板块学术版
  • 楼主zren6ing
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/8/9 20:13
  • 上次更新2023/11/3 04:53:08
查看原帖
捞,subtask3 #9WA了,其他都A了,悬1关。
516714
zren6ing楼主2023/8/9 20:13
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << 1 << "\n";
  } else if (n == 2) {
    cout << 1 << " " << 2 << "\n";
  } else if (n == 3) {
    cout << 1 << " " << 1 << " " << 2 << "\n";
  } else if (n == 4) {
    cout << 1 << " " << 2 << " " << 1 << " " << 2 << "\n";
  } else if (n == 5) {
    cout << 1 << " " << 2 << " " << 1 << " " << 1 << " " << 3 << "\n";
  } else if (n % 3 == 0) {
    for (int i = 1; i <= n / 3; i++) {
      cout << 1 << " " << i + 1 << " " << 1 << " ";
    }
  } else {
    int num = 0;
    for (int i = 1; i <= n; i++) {
      cout << 1 << " " ;
      num++;
      if (num >= n) {
        return 0;
      }
      cout << i + 1 << " " ;
      num++;
      if (num >= n) {
        return 0;
      }
      cout << 1 << " ";
      num++;
      if (num >= n) {
        return 0;
      }
    }
  }
  return 0;
}

程序有点臭长,见谅。

2023/8/9 20:13
加载中...