题目地址: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");
    ;
}

gym101090 I Painting the natural numbers的更多相关文章

  1. 2016-2017 CT S03E02: Codeforces Trainings Season 3 Episode 2

    A HHPaint B Square Root C Interesting Places D Road to Home E Ant and apples F Square G Pair H The F ...

  2. CodeForces 55D Beautiful numbers

    D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standar ...

  3. [codeforces 55]D. Beautiful numbers

    [codeforces 55]D. Beautiful numbers 试题描述 Volodya is an odd boy and his taste is strange as well. It ...

  4. codeforces 55D - Beautiful numbers(数位DP+离散化)

    D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standar ...

  5. UVA 11481 - Arrange the Numbers 数学

    Consider this sequence {1, 2, 3, . . . , N}, as a initial sequence of first N natural numbers. You ca ...

  6. Project Euler 88:Product-sum numbers 积和数

    Product-sum numbers A natural number, N, that can be written as the sum and product of a given set o ...

  7. Codeforces Beta Round #51 D. Beautiful numbers 数位dp

    D. Beautiful numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/p ...

  8. Codeforces Beta Round #51 D. Beautiful numbers

    D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standar ...

  9. ural 1118. Nontrivial Numbers

    1118. Nontrivial Numbers Time limit: 2.0 secondMemory limit: 64 MB Specialists of SKB Kontur have de ...

随机推荐

  1. Android笔记——Android中数据的存储方式(三)

    Android系统集成了一个轻量级的数据库:SQLite,所以Android对数据库的支持很好,每个应用都可以方便的使用它.SQLite作为一个嵌入式的数据库引擎,专门适用于资源有限的设备上适量数据存 ...

  2. CRUD Operations in MVC4 Using AngularJS and WCF REST Services

    Now in this article I will show how to do Create, Retrieve, Update and Delete (CRUD) operations in M ...

  3. 【高级功能】使用canvas元素(第二部分)

    本文将继续介绍canvas的功能,展示如何绘制更复杂的图形(包括圆弧和曲线),如何使用剪裁区域来限制操作以及如何绘制文本.还是介绍可以应用在画布上的特效和变换,包括阴影.透明度.旋转和坐标重映射. 1 ...

  4. Microsoft Dynamics CRM 2013 CD-KEY

    Microsoft Dynamics CRM Workgroup Server 2013 (5 CAL limit):NX77Y-BTBCV-JP3T3-8W7JH-94QJP Microsoft D ...

  5. FIJ Jobs – 2013/8/12

    Department Vacancies Total Skill Set Experience Language Systems Systems Coordinator 1 Communication ...

  6. 打造高仿QQ的友盟反馈界面(MVP模式)

    什么是MVP呢,简单来说就是将view层和逻辑完全独立出来,让逻辑和显示完全独立.本例中就是采用了这种模式,让activity作为view层,activity中涉及了适配器,所以这里尝试让适配器作为P ...

  7. Mac 以太网连接 报无效的服务器地址 BasicIPv6ValidationError

    Mac 以太网连接 报无效的服务器地址 BasicIPv6ValidationError 用Mac这么久,一直是用WiFi连接网络,没搞过以太网连接,我也是醉了 显然 Mac 不能像 Windows ...

  8. page resizing

    <script type="text/javascript"> $(window).load(function () { var root; root = $(&quo ...

  9. UITabBarController的创建等基本方法

    #import "AppDelegate.h" @interface AppDelegate () <UITabBarControllerDelegate> @end ...

  10. tp_link路由器 重新设置

    当打不开网站,而提示让我们登录电信猫时,通常是由于突然断电导致的路由器程序错误.重新路由器设置即可.     1.路由器恢复出厂设置       2.用网线分别连接电脑和路由器的LAN口.(也就是将 ...