山东省第七届ACM大学生程序设计竞赛 A题 Julyed

题意:

有n个单词,每天这个人可以背m个,问你最少几天可以背完,签到题

分析:

input
5
6 3
2 1
1 2
5 2
4 3
Output
2
2
1
3
2

分析几个案例:
第一个案例:6个单词,每天可以背3个,两天可以背完
第三个案例:1个单词,每天可以背2个,一天可以背完
第四个案例:5个单词,每天可以背2个,三天可以背完

代码:

#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <algorithm>
#include <queue>
#include <map>
#define ll long long;
#define debug cout<<"********"<<endl;
using namespace std;
const int maxn = 1e9+5;
const int mod = 1e9+7;
int main(){
    std::ios::sync_with_stdio(false);
    int T;cin>>T;
    while(T--){
        int a,b;
        cin>>a>>b;
        if(a < b){
            cout<<1<<endl;
        }
        else{
            int c = a / b;
            if(c * b >= a){
                cout<<c<<endl;
            }else{
            cout<<c+1<<endl;}
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/shensiback/article/details/80166597