| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 148047 | 罗迎甲 | 14能吸多少根烟 | C++ | Compile Error | 0 MS | 0 KB | 712 | 2026-02-09 15:16:35 |
include<bits/stdc++.h> using namespace std; int main(){ int n, k; cin >> n >> k; // 输入初始烟数n,换1根烟需要的烟蒂数k int total = n; // 最终吸的总烟数,初始为n(先吸完所有初始烟) int butts = n; // 剩余烟蒂数,初始吸完n根烟产生n个烟蒂 // 循环换烟:烟蒂数足够换1根新烟时继续 while (butts >= k) { int new_cig = butts / k; // 本次能换的新烟数 total += new_cig; // 总吸烟数增加 // 更新烟蒂数:换烟剩下的烟蒂 + 吸新烟产生的烟蒂 butts = (butts % k) + new_cig; } cout << total << endl; return 0; }
Main.cc:1:1: error: 'include' does not name a type
include
^
Main.cc: In function 'int main()':
Main.cc:6:5: error: 'cin' was not declared in this scope
cin >> n >> k; // 输入初始烟数n,换1根烟需要的烟蒂数k
^
Main.cc:19:5: error: 'cout' was not declared in this scope
cout << total << endl;
^
Main.cc:19:22: error: 'endl' was not declared in this scope
cout << total << endl;
^