#include<iostream>
using namespace std;
int rooms(int x,int k){
    if(x%k==0){
        return x/k;
    }
    else{
        return (x/k)+1;
    }
}
int main(){
    int t;
    cin>>t;
    while(t--){
        int m,n,k;
        cin>>m>>n>>k;
        int boys_rooms=rooms(m,k);
        int girls_rooms=rooms(n,k);
        int total_rooms=boys_rooms+girls_rooms;
        cout<<total_rooms<<"\n";
    }    
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: