From 04fa87a8da22ca3fd199d9337b35f0548965c8c0 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 19 May 2024 15:21:35 +0800 Subject: [PATCH] =?UTF-8?q?:white=5Fcheck=5Fmark:=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E9=98=9F=E5=88=97=E8=A7=A3=E5=86=B3=E6=8A=A5=E6=95=B0=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reporting-number/main.cc | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 reporting-number/main.cc diff --git a/reporting-number/main.cc b/reporting-number/main.cc new file mode 100644 index 0000000..61538c2 --- /dev/null +++ b/reporting-number/main.cc @@ -0,0 +1,35 @@ +#include +#include +#include +#include +using namespace std; +int main() { + queue q; + int X, Y, K; + cin >> X >> Y >> K; + for (int i = 1; i <= X + Y; i++) { + q.push(i); + } + int count = 0; + while (q.size() > X) { + count++; + if (count == K) { + q.pop(); + count = 0; + } else { + auto pin = q.front(); + q.pop(); + q.push(pin); + } + }; + vector v; + while (q.size() > 0) { + v.push_back(q.front()); + q.pop(); + } + sort(v.begin(), v.end()); + for (int i = 0; i < v.size(); i++) { + printf("%d ", v[i]); + } + printf("\n"); +}