#include #include #include void main() { int i, j, k; int numsets, nump, firstp; int cake[100]; int total; scanf("%d", &numsets); for (i=1; i<=numsets; i++) { scanf("%d %d", &nump, &firstp); cake[1] = firstp; for (j=2; j<=nump; j++) { if (j%7==0) cake[j] = j%11+1; else if ( sqrt((float)j) - (float)(int)sqrt((float)j) < 0.00001) { cake[j] = (int)floor(sqrt((float)j)+.0001); //printf("perfect: %d\n", j); } else if (j%2==0) cake[j]=cake[j-1]+1; else if (cake[j-1]==0) cake[j]=cake[1]; else cake[j]=cake[j-1]-1; //printf("person %d: cake %d\n", j, cake[j]); } total=0; for (j=1; j<=nump; j++) total += cake[j]; printf("Data set %d: %d units of cake are eaten.\n", i, total); } }