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");
;
}
gym101090 I Painting the natural numbers的更多相关文章
- 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 ...
- CodeForces 55D Beautiful numbers
D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standar ...
- [codeforces 55]D. Beautiful numbers
[codeforces 55]D. Beautiful numbers 试题描述 Volodya is an odd boy and his taste is strange as well. It ...
- codeforces 55D - Beautiful numbers(数位DP+离散化)
D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standar ...
- UVA 11481 - Arrange the Numbers 数学
Consider this sequence {1, 2, 3, . . . , N}, as a initial sequence of first N natural numbers. You ca ...
- 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 ...
- 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 ...
- Codeforces Beta Round #51 D. Beautiful numbers
D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standar ...
- ural 1118. Nontrivial Numbers
1118. Nontrivial Numbers Time limit: 2.0 secondMemory limit: 64 MB Specialists of SKB Kontur have de ...
随机推荐
- 程序设计模式 —— State 状态模式
我应该如何阅读? 本文将使用优雅的文字风格来告诉你什么是状态模式. 注意: 1.在阅读本文之前请保证你已经掌控了 面对对象的思想与 多态的基本概念,否则将难以理解. 2.本文实现将用C++实现,你不一 ...
- 开发机多用户 xdebug 远程调试 PhpStorm
在公司都用的远程开发机开发,每次有错误调试就得dd(xxx)然后保存真是,让我在本地开发用惯xdebug的情何以堪,所以有了下文. 1.安装配置xdebug 直接使用pecl安装即可 # pecl i ...
- 微信公共平台开发4 .net
之前说了让微信发送给关注我们的粉丝普通的文本信息,下面我们来看看如何发送图文信息,需要注意的是这里说的是,让微信发给我们,而不是我们拍个图片发给微信处理,上传图片在以后的再讲.下面是发送图文消息的函数 ...
- python初识(2)
1.关于编码转换的方式. 比如,讲utf-8的编码转换为unicode方式如下 #-*- coding:utf-8 -*- i="德玛西亚" i_unicode=i_decode( ...
- java调用html模板发送html内容的邮件
在项目需要发送邮件,普通内容的邮件觉得太单调.太丑,没逼格,所以说直接把用到的邮件内容做成一个html模板,发送之前将对应参数替换掉,发送html内容的高逼格邮件. 首先需要引用jar包,这就不多说了 ...
- Access sql语句创建表及字段类型
创建一张空表: Sql="Create TABLE [表名]" 创建一张有字段的表: Sql="Create TABLE [表名]([字段名1] MEMO NOT NUL ...
- Sharepoint学习笔记—习题系列--70-573习题解析 -(Q51-Q53)
Question 51You use a third-party site definition to create SharePoint sites.You need to add a Web Pa ...
- 异步get请求之代理方法
#import "ViewController.h" #import "Header.h" @interface ViewController ()<NS ...
- .NET下的并行开发
并行开发一直是程序员在开发项目中遇到的一道坎,但为了迎合硬件的升级,面对高端多核的处理器,并行编程势在必行.在.NET平台下的开发支持并行模式,下面用一个实际项目说明并行的高效率和神奇之处. 在优化中 ...
- iOS开发之网络编程--6、NSURLSessionConfiguration笔记
NSURLSessionConfiguration对象用于初始化NSURLSession对象. 展开请求级别中与NSMutableURLRequest相关的可供选择的方案,我们可以看到NSURLSes ...