ZeroJudge F754: DD Cries

"DD," full name "Dat Derek," stands at 156.4 cm tall and weighs 89.2 kg (though that was measured a few years ago; by now, it's probably over a hundred...)

He suffers from foot odor, doesn't care much about cleanliness, and doesn't bother to brush his dirty teeth. To him, a mouthful of yellow teeth is a symbol of fashion.

His hair is dirty and unkempt, never groomed, letting dandruff fly around like seeds being scattered.

He's often labeled with titles like "dirty devil," "loser," "failure in life," "chubby otaku"... and the like.

However, he harbors a heart full of longing for love.

DD was bullied today. Please help him seek justice.

DD's $M will be evenly distributed among K people. (0 < K < M < 300000000000)

If it cannot be divided evenly, the remaining money will be given to the last person.

Please output which test case and which person received how much money, followed by "DD! BAD!"

Sample Inputs/Outputs

Sample Input(s)Sample Output(s)
The first line will contain an integer N.
Then there are N sets of data.
Each set of data consists of two integers, M and K.
Please output which test case and which person received how much money, followed by "DD! BAD!"
2
1 1
4 3
Case 1 :
第1位 : 拿1元並說DD! BAD!
Case 2 :
第1位 : 拿1元並說DD! BAD!
第2位 : 拿1元並說DD! BAD!
第3位 : 拿2元並說DD! BAD!

Thought Process

When collecting data for this problem, you need to use Long Long Int. In addition, K may be 0. When K is 0, you only need to output the number of the current case and then move on to the next case.

Sample Code-ZeroJudge F754: DD Cries

#include <iostream>
using namespace std;

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    for (int i = 0; i<N; i++)
    {
        long long int M, K;
        cin >> M >> K;
        cout << "Case " << i+1 << " :\n";
        if (K != 0)
        {
            long long int give = M/K;
            long long int last = 0;
            if (M % K != 0) last = M % K;
            for (int i = 1; i<K; i++)
            {
                cout << "第" << i << "位 : 拿" << give << "元並說DD! BAD!\n";
            }
            cout << "第" << K << "位 : 拿" << give+last << "元並說DD! BAD!\n";
        }
    }
}

//ZeroJudge F754
//Dr. SeanXD

Comments