Wednesday, January 15, 2014

codechef SPCANDY - "splitting candies" solution

codechef SPCANDY - "splitting candies": http://www.codechef.com/problems/SPCANDY

codechef SPCANDY - "splitting candies" solution: http://ideone.com/19BYF0

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
int t;
long long n, k;
scanf("%d", &t);
while(t--) {
scanf("%lld", &n); 
scanf("%lld", &k);
if(k==0) printf("0 %lld\n", n);
else printf("%lld %lld\n", n/k, n%k);
}
return 0;
}

note: just pay attention to k, whether if it is 0 or not

No comments:

Post a Comment