[2024年3月10日]第15届蓝桥杯青少组stema选拔赛C++中高级(第二子卷、编程题(1))

参考程序1

cpp 复制代码
#include <iostream>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    
    // 计算最少天数
    int days = n / m; // 先除以 m 得到整天数
    if (n % m != 0) { // 如果还有剩余试卷,增加一天
        days++;
    }
    
    cout << days << endl;
    
    return 0;
}

参考程序2

cpp 复制代码
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  cout<<n/m+(n%m!=0);
  return 0;
}

参考程序3

cpp 复制代码
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  cout<<(n+m-1)/m;
  return 0;
}

参考程序4

cpp 复制代码
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  int ans;
  cin>>n>>m;
  cout<<int(ceil(1.0*n/m));
  return 0;
}
相关推荐
·present·2 小时前
CSAPP(lecture 4_01)
c语言·c++
FPGA小迷弟2 小时前
用 Claude Code 重构遗留系统:从评估到落地的完整实践指南
c++·python·ai·plotly·django·ai编程·claude
程序员-King.2 小时前
【ROS1】Noetic 开发工作流程与常用命令
c++·ubuntu·ros
云深麋鹿2 小时前
C++ | 基于红黑树实现mymap与myset
开发语言·c++
傲世仙尊4 小时前
string增删查改-insert-erase-replace与find加substr组合技
c++
·present·6 小时前
CSAPP(lecture 3)
c++
别动我齐刘海6 小时前
机器人 C++ / 系统联调补强2——异常处理、Protobuf
linux·c++·人工智能·学习·算法·机器学习·机器人
basketball6166 小时前
C++ 中字符串与常见类型的转换总结
开发语言·c++
等我调个Bug7 小时前
C++智能指针通俗讲解
开发语言·c++
kyle~9 小时前
时间同步 --- PTP 与 Scheduled Action Command
c++·数码相机·机器人·传感器