UVA Solution 440 - Eeny Meeny Moo - Code in C, C++ - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Thursday, May 11, 2017

UVA Solution 440 - Eeny Meeny Moo - Code in C, C++

UVA Solution 440 - Eeny Meeny Moo - Code in C, C++

UVA Online Judge Solution 440 - Eeny Meeny Moo | Volume 4
UVA Problem Link - https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=6&page=show_problem&problem=381

Problem Name: 440 - Eeny Meeny Moo
Problem Number : UVA - 440 - Eeny Meeny Moo
Online Judge : UVA Online Judge Solution
Volume: 4
Solution Language : C, C plus plus

UVA Online Judge Solution, UVA OJ Solution list, UVA Problems Solution, UVA solver, UVA all problem solution list

UVA Solution 440 - Eeny Meeny Moo Code in C,CPP:

#include <stdio.h>
#include <stdlib.h>
int Calu(int n, int k) {
 static int link[151], i, j, head, prev, last;
 for(i = 2; i < n; i++)
  link[i] = i+1;
 link[n] = 2, head = 2, prev = n;
 for(i = 1; i < n; i++) {
  for(j = 1; j < k; j++)
   prev = head, head = link[head];
  last = head;
  link[prev] = link[head];
  head = link[head];
 }
 if(last == 2)  return 1;
 return 0;
}
int main() {
 int D[150], N, count, i;
 for(i = 3; i < 150; i++) {
  count = 2;
  while(Calu(i, count) == 0) count++;
  D[i] = count;
 }
 while(scanf("%d", &N) == 1 && N) {
  printf("%d\n", D[N]);
 }
    return 0;
}


Tags: UVA Online Judge Solution, UVA OJ Solution list, UVA  440 - Eeny Meeny Moo  Problems Solution, UVA solver, UVA all problem solution list, UVA Eeny Meeny Moo  code in C, UVA 440   code in C++, UVA Eeny Meeny Moo solution in C, UVA 440 solution

No comments:

Post a Comment