题目地址: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. gene框架文档 - 路由类 gene_router

    路由类 Gene\Router 介绍 Gene\Router 是gene框架的核心类之一,本框架区别于其他常见框架的最大地方就是独特.强大.简单的路由定义等.路由强大灵活,支持回调.类方法:支持res ...

  2. map与vector---Email Aliases

    Description Polycarp has quite recently learned about email aliases. Of course, he used to suspect t ...

  3. 泛函编程(13)-无穷数据流-Infinite Stream

    上节我们提到Stream和List的主要分别是在于Stream的“延后计算“(lazy evaluation)特性.我们还讨论过在处理大规模排列数据集时,Stream可以一个一个把数据元素搬进内存并且 ...

  4. [moka同学笔记]linux服务器防火墙的设置

    网站突然打不开:服务器停止了,重启后,防火墙自动启动,导致网站打不开. 1.查看防火墙 systemctl status firewalld 2.关闭防火墙 systemctl stop firewa ...

  5. Hibernate中的一级缓存、二级缓存和懒加载(转)

    1.为什么使用缓存 hibernate使用缓存减少对数据库的访问次数,从而提升hibernate的执行效率.hibernate中有两种类型的缓存:一级缓存和二级缓存. 2.一级缓存 Hibenate中 ...

  6. ahjesus 让Boot Camp支持创建win7 u盘安装盘

    通过修改BootCamp助理成功创建USB的windows7的安装盘. 以下将方法共享出来. 准备工作: 找到自己电脑的Boot Rom 版本.(点左上角那个小苹果标志 然后点 [关于本机] 然后点 ...

  7. ASP.NET Core 1.0开发Web API程序

    .NET Core版本:1.0.0-rc2Visual Studio版本:Microsoft Visual Studio Community 2015 Update 2开发及运行平台:Windows ...

  8. SilverLight MD5加密

    效果体验:http://keleyi.com/tool/md5.htm 嵌入页面的代码: <div style="width:400px;height:230px"> ...

  9. 用js枚举实现简易菜单效果

    用js枚举实现简易菜单效果,左侧显示菜单,右侧显示用户选择的菜单,一图胜千言,还是直接来张效果图吧: 以下是代码: <DOCTYPE html> <html> <head ...

  10. ASP.NET MVC的请求生命周期

    我希望能理解在浏览器输入URL并敲击回车来请求一个ASP.NET MVC网站的页面之后发生的任何事情. 为什么需要关心这些?有两个原因.首先是因为ASP.NET MVC是一个扩展性非常强的框架.例如, ...