Monday, September 26, 2011

ACM - UVA 305 - Joseph

Problem : 305 - Joseph
Solution : C++
Hints : http://algorithmist.com/index.php/UVa_305

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <sstream>
#include <set>
#include <math.h>
using namespace std;
int Val[] = {0,2,7,5,30,169,441,1872,7632,1740,93313,459901,1358657,2504881};

int main()
{
    int N;
    while(scanf("%d",&N) && N)
    {
          printf("%d\n",Val[N]);       
    }
    return 0;
}

No comments:

Post a Comment