CMIYC - Catch Me If You Can (link to the question)
It's easy one So i'm gonna give the brief idea of it .
Let take some cases :
what if the n could be 3,4,5,6,7,8,9,10 ( 1,2 are already taken under sample example).
try to analyze the pattern . then you'll get 3,6,9, or in other words multiple of 3 as ON and rest as zero.
so the answer for the multiple of 3 would be (given number divided by 3) num/3 and rest are zero.
: : : : : : : : : : : : : : : : : : : : Here is your code : : : : : : : : : : : : : : : : : : : : : : : :
#include<stdio.h> int main() { int t; long long n; scanf("%i",&t); while(t--) { scanf("%lli",&n); (n%3) ? printf("0\n") : printf("%lld\n",n/3); } return 0; }
No comments:
Post a Comment
Your comment is valuable to us