gym101090 I Painting the natural numbers

时间:2023-03-09 19:09:37
gym101090 I Painting the natural numbers

题目地址:http://codeforces.com/gym/101090

题目:

  The H&H company currently develops AI (artificial intelligence) for the game. The goal of the game is to paint all the natural numbers from 1 to N in 10 colors so that if the numbers a and b (a and b are not necessarily different) are one color, then a+b has to be another color. Help H&H.

  Input

      The input consists of the only integer N (1 ≤ N ≤ 25000).

  Output

      Output N numerals from 0 to 9 (each numeral indicates the color of the current number). If solutions does not exist, write N zeros to the output.

  Example standard input standard output

            10   0102010301

题解:

I: Suppose, you know how to color N cells using just K colors. Then using K + 1 colors you can easily color3 * N + 1 cells, like this:

{ old thing with K colors }{ N + 1 cells with new color }{ old thing with K colors }

This will give 0110222220110 for 3 colors. Overall it allows you to color up to 29k cells with 10 colors.

代码:

#include <bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
;
const double pi=acos(-1.0);
;
int c[K];
int main(void)
{
    int n;cin>>n;
    ;
    ;i<;i++)
    {
        ;j<=cur*+;j++)c[j]=i;
        +;j<=*cur+;j++)c[j]=c[j-cur*-];
        cur=cur*+;
    }
    ;i<=n;i++)
        printf("%d",c[i]);
    printf("\n");
    ;
}