题目地址: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. KMP--Simpsons’ Hidden Talents

    题目网址:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=110060#problem/C Description Homer: Marge ...

  2. 两种设计模式(1)==>>“简单工厂”

    我们以做一个计算器为例,给大家介绍简单工厂的应用: 效果: 这里我们使用 继承 ,虚方法, 简单工厂的设计模式来完成 首先,我们除了搭好窗体外,我们应该把我们的一些类准备好: 1.计算的父类Calcu ...

  3. Linux_Centos中搭建nexus私服

    1.在Linux下搭建Nexus私服 1).下载并且解压      下载  nexus-2.11.2-03-bundle.zip      unzip nexus-2.11.2-03-bundle.z ...

  4. Silverlight的TextWrapping

    Silverlight中TextBox的TextWrapping属性,作用是获取或设置 TextBlock 对文本进行换行的方式. 默认值为 TextWrapping.NoWrap. TextWrap ...

  5. [原创]winform_PC宴会图片抽奖/文字抽奖

    14年6月 好友结婚 14年4月左右知道他们婚礼由迎宾照抽奖的环节 问我有没有可以用的抽奖软件 我网上找了一会儿,就放弃了,自己做一个更快不是? 14年6月,PC宴会图片抽奖软件成功使用 --- 操作 ...

  6. 一些js小题(一)

    一些js小题,掌握这些对于一些常见的面试.笔试题应该很有帮助: var a=10; function aa(){ alert(a); } function bb(){ aa(); } bb();//1 ...

  7. 关于HTML的编码问题

    平时我在写html文件时,很容易忘掉这个文件的编码类型,<meta charset=”utf-8”> 的语句,因为编辑器默认设置了一个编码,所以在我没有写编码格式设置语句的情况下,效果依然 ...

  8. 如何利用ArcGIS Engine接口实现打开Raster Catalog中的某一幅指定的影像?

    将IRasterCatalog转化为ITable,然后通过ITable.GetRow返回指定索引的IRow,将IRow转为IRasterCatalogItem,进而获取IRasterCatalogIt ...

  9. Android软键盘与输入框的设置

    大家开发Android或者用app的时候会发现转到输入框就会自动弹出软键盘,切换别的页面就会自动的隐藏,下面几行代码用的熟练了就行了: 1.方法一(如果输入法在窗口上已经显示,则隐藏,反之则显示) I ...

  10. iOS提醒用户进入设置界面进行重新授权通知定位等功能

    iOS 8及以上版本最不为人知的一个特点是与应用设置的深层链接,用户可以根据APP的需要授权启用位置.通知.联系人.相机.日历以及健康等设置. 大多数应用程序仅仅是弹出一个包含操作指令的警示窗口,如“ ...