Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- long long N, K;
- // Input the number of cakes (N) and the number of guests (K)
- scanf("%lld %lld", &N, &K);
- // Case 1: No guests (K == 0)
- if (K == 0) {
- printf("Sorry, it's not possible to share the cakes equally!\n");
- }
- // Case 2: More guests than cakes (N < K)
- else if (N < K) {
- printf("Sorry, it's not possible to share the cakes equally!\n");
- }
- // Case 3: Check if cakes can be evenly distributed (N % K == 0)
- else if (N % K == 0) {
- printf("%lld\n", N / K);
- }
- // Case 4: Cakes cannot be distributed equally (N % K != 0)
- else {
- printf("Sorry, it's not possible to share the cakes equally!\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement