Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/ #include <stdio.h> #include <math.h> int main() { int tst, i, j; double a; scanf("%d", &tst); for(i=1; i<=tst; i++) { int n, cnt=0; scanf("%d", &n); int ara[n]; for(j=0; j<n; j++) scanf("%d", &ara[j]); a = ara[0]-2; cnt = ceil(a/5.0); for(j=1; j<n; j++) { a = ara[j]-ara[j-1]; cnt += ceil(a/5.0); } printf("Case %d: %d\n", i, cnt); } return 0; }
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.