poj 1012

#include <stdio.h>
#include <string.h>
#include <time.h>

double start,finish;

int check(int m, int k)
{
    int remainder = 0;
    int position = 0;
    int count = 0;
    
    for(count = 2 * k; count != k; count--)
    {
        remainder = m % count;
        position = (remainder + position + 1) % count;
        if(position <= k)
        {
            return 0;
        }
    }
    
    return 1;
}

int main(int argc, char *argv[])
{
    int m = 0;
    int k = 0;
    
    scanf("%d", &k);
    
    m = k + 1;

    while(1)
    {
        if(check(m, k))
        {
            break;
        }
        
        m++;
    }

    printf("%d", m);
    
    return 0;
}

 

posted @ 2014-01-21 17:58  reasontom  阅读(107)  评论(0编辑  收藏  举报