Codeforces 758D Ability To Convert(区间DP)
题目链接:http://codeforces.com/problemset/problem/758/D
题意:一个n进制下的数k,其中k不会用字母,如果有A就用10代替了。求k这个数对应的,在10进制下最小的数。
分析:
- #include<cstdio>
- #include<cstring>
- #include<cstdlib>
- #include<cmath>
- #include<iostream>
- #include<algorithm>
- using namespace std;
- typedef long long ll;
- const ll INF=(1LL<<)-;
- char s[];
- ll dp[];
- int main()
- {
- int n;
- scanf("%d%s",&n,s+);
- int len=strlen(s+);
- for(int i=; i<=len; i++)
- dp[i]=INF;
- dp[]=;
- for(int i=; i<=len; i++)
- {
- ll now=;
- for(int j=i; j<=len; j++)
- {
- now=now*+s[j]-'';
- if(now>=n)break;
- if(s[i]=='' && j>i)break;
- if(1.0*dp[i-]*n+now>2e18)continue;
- dp[j]=min(dp[j],dp[i-]*n+now);
- }
- }
- printf("%lld",dp[len]);
- return ;
- }
Codeforces 758D Ability To Convert(区间DP)的更多相关文章
- codeforces 758D Ability To Convert【DP】
在N进制下给你一个数,要你转换成最小的十进制数; 状态转移方程:从前向后 dp[j]表示j位前数列的最小十进制数 dp[j]=min(dp[j],dp[i]*n+x) 程序: #include < ...
- Codeforces Round #392 (Div. 2)-758D. Ability To Convert(贪心,细节题)
D. Ability To Convert time limit per test 1 second Cmemory limit per test 256 megabytes input standa ...
- Educational Codeforces Round 61 F 思维 + 区间dp
https://codeforces.com/contest/1132/problem/F 思维 + 区间dp 题意 给一个长度为n的字符串(<=500),每次选择消去字符,连续相同的字符可以同 ...
- Codeforces Gym100543L Outer space invaders 区间dp 动态规划
原文链接https://www.cnblogs.com/zhouzhendong/p/CF-Gym100543L.html 题目传送门 - CF-Gym100543L 题意 $T$ 组数据. 有 $n ...
- Codeforces 508E Arthur and Brackets 区间dp
Arthur and Brackets 区间dp, dp[ i ][ j ]表示第 i 个括号到第 j 个括号之间的所有括号能不能形成一个合法方案. 然后dp就完事了. #include<bit ...
- codeforces 1101F Trucks and Cities 区间dp+单调优化 好题
题目传送门 题意简述:(来自洛谷) 有n个城市坐落在一条数轴上,第ii个城市位于位置ai. 城市之间有m辆卡车穿行.每辆卡车有四个参数:si为起点编号,fi为终点编号,ci表示每行驶1个单位长 ...
- Codeforces 509F Progress Monitoring:区间dp【根据遍历顺序求树的方案数】
题目链接:http://codeforces.com/problemset/problem/509/F 题意: 告诉你遍历一棵树的方法,以及遍历节点的顺序a[i],长度为n. 问你这棵树有多少种可能的 ...
- CodeForces 149D Coloring Brackets (区间DP)
题意: 给一个合法的括号序列,仅含()这两种.现在要为每对括号中的其中一个括号上色,有两种可选:蓝or红.要求不能有两个同颜色的括号相邻,问有多少种染色的方法? 思路: 这题的模拟成分比较多吧?两种颜 ...
- 【非原创】codeforces 1025D - Recovering BST【区间dp+二叉搜索树】
题目:戳这里 题意:给一个不下降序列,有n个数.问能否构造一个二叉搜索树,满足父亲和儿子之间的gcd>1. 解题思路:其实这题就是构造个二叉搜索树,只不过多了个条件.主要得了解二叉搜索树的性质, ...
随机推荐
- python模块之numpy
Numpy是一个第三方库,是数组相关的运算 通过pip安装:pip install numpy Anaconda python的一个科学计算发行版本,安装后将不必单独安装numpy,下面的库模块也将不 ...
- 修改jupyter notebook的默认浏览器
1.打开命令行 2.输入jupyter notebook --generate-config 3.显示出jupyter_notebook_config.py 文件所在的目录.按文件目录找到这个文件. ...
- Thread.GetNamedDataSlot(String)
https://docs.microsoft.com/zh-cn/dotnet/api/system.threading.thread.getnameddataslot?redirectedfrom= ...
- Typora中给代码块设置快捷键
Tpyore中大部分的操作都是有快捷键的.但是有那么几个常用的却没有快捷键.就比如代码块,这个常用的操作,还有有序无需列表. 下边教会你怎么设置快捷键,打开设置,Preferences[偏好设置],然 ...
- redis初步学习 0
2.1 Redis是什么 REmote DIctionary Server(Redis) 是一个由Salvatore Sanfilippo写的key-value存储系统.Redis提供了一些丰富的数据 ...
- Linux添加、创建新用户
给Linux添加新用户,新建用户,新建帐号 添加用户组 sudo groupadd groupname 添加用户 sudo useradd username -m -s /bin/bash -d /h ...
- 统计学howto
统计之都 http://cos.name/ 让你拥有超能力:程序员应该掌握的统计学公式 Statistical Formulas For Programmers http://www.evanmill ...
- UI3D转2D平面显示UI3DTo2D血条显示
UI3D转2D平面显示UI3DTo2D血条显示: using UnityEngine; using System.Collections; public class UI3DTo2D : MonoBe ...
- day06 - Python - 面向对象
本节内容: 引子 面向对象 v.s. 面向过程 面向对象编程介绍 面向对象的特性: 封装 继承 多态 类.方法 1.引子 假设你现在是一家游戏公司的开发人员,现 ...
- Spring boot-(2) Spring Boot使用
1. 构建系统 (1) 使用maven构建 1) 从Starter Parent继承 在项目中配置继承spring-boot-starter-parent,可以进行如下设置: <!-- Inhe ...