Codeforces Round #265 (Div. 2) E
这题说的是给了数字的字符串 然后有n种的操作没次将一个数字替换成另一个字符串,求出最后形成的字符串的 数字是多大,我们可以逆向的将每个数推出来,计算出他的值和位数记住位数用10的k次方来记 1位就是10 2位就是100,这样是为了防止当位数很大的时候存不下这样可以直接的进行mod操作
#include <iostream>
#include <cstdio>
#include <string.h>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int max_n=;
const ll mod= ;
struct point{
ll val,loc;
}digit[];
char str[max_n];
vector<int> F[max_n];
char S[max_n];
int n;
int main()
{
while(scanf("%s",str)==){
for(int i=; i<; ++i)
digit[i].loc=,digit[i].val=i;
scanf("%d",&n);
for(int i=; i<n; i++){
F[i].clear();
scanf("%s",S);
F[i].push_back(S[]-'');
int len=strlen(S);
for(int j=; j<len; ++j)
F[i].push_back(S[j]-'');
}
for(int i =n-; i>=; --i )
{
ll val=,loc=;
int L =F[i].size();
for(int k=L-; k>; --k){
int t =F[i][k];
val=(val+loc*digit[t].val)%mod;
loc=(loc*digit[t].loc)%mod;
}
digit[F[i][]].loc=loc;
digit[F[i][]].val=val;
}
ll ans=,loc=;
int L =strlen(str);
for(int i=L-; i>=; --i){
ll t= str[i]-'';
ans=(ans+digit[t].val*loc)%mod;
loc=(loc*digit[t].loc)%mod;
}
printf("%I64d\n",ans);
}
return ;
}
Codeforces Round #265 (Div. 2) E的更多相关文章
- Codeforces Round #265 (Div. 1) C. Substitutes in Number dp
题目链接: http://codeforces.com/contest/464/problem/C J. Substitutes in Number time limit per test 1 sec ...
- Codeforces Round #265 (Div. 2) C. No to Palindromes! 构建无回文串子
http://codeforces.com/contest/465/problem/C 给定n和m,以及一个字符串s,s不存在长度大于2的回文子串,如今要求输出一个字典比s大的字符串,且串中字母在一定 ...
- Codeforces Round #265 (Div. 2) E. Substitutes in Number
http://codeforces.com/contest/465/problem/E 给定一个字符串,以及n个变换操作,将一个数字变成一个字符串,可能为空串,然后最后将字符串当成一个数,取模1e9+ ...
- Codeforces Round #265 (Div. 2) D. Restore Cube 立方体判断
http://codeforces.com/contest/465/problem/D 给定8个点坐标,对于每个点来说,可以随意交换x,y,z坐标的数值.问说8个点是否可以组成立方体. 暴力枚举即可, ...
- Codeforces Round #265 (Div. 2) C. No to Palindromes! 构造不含回文子串的串
http://codeforces.com/contest/465/problem/C 给定n和m,以及一个字符串s,s不存在长度大于2的回文子串,现在要求输出一个字典比s大的字符串,且串中字母在一定 ...
- Codeforces Round #265 (Div. 2) D. Restore Cube 立方体推断
http://codeforces.com/contest/465/problem/D 给定8个点坐标.对于每一个点来说,能够任意交换x.y,z坐标的数值. 问说8个点能否够组成立方体. 暴力枚举就可 ...
- Codeforces Round #265 (Div. 2)
http://codeforces.com/contest/465 rating+7,,简直... 感人肺腑...............蒟蒻就是蒟蒻......... 被虐瞎 a:inc ARG 题 ...
- Codeforces Round #265 (Div. 2) B. Inbox (100500)
Over time, Alexey's mail box got littered with too many letters. Some of them are read, while others ...
- Codeforces Round #265 (Div. 1)
D. World of Darkraft - 2 time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
随机推荐
- linux安装oracle11g步骤
1. 修改用户限制 root用户:修改 /etc/security/limits.conf 文件,加上下面的参数 oracle soft nproc 2047 oracle hard nproc 16 ...
- 《C++ Primer Plus》15.5 类型转换运算符 学习笔记
C++相对C更严格地限制允许的类型转换,并添加4个类型转换运算符,是转换过程更规范:* dynamic_cast:* const_cast:* static_cast:* reinterpret_ca ...
- 《转》python学习(5)--数据类型
转自 http://www.cnblogs.com/BeginMan/archive/2013/06/08/3125876.html 一.标准类型函数 cmp():比较大小 str():转换为字符串 ...
- c++字符指针
对于C/C++中的 字符指针和字符数组,总是在碰到的时候无法确定而不得不现场测试,来确定末尾是否包含'\0',函数到底如何使用等等.真是劳民伤财,现在总结一下: 字符指针的赋值 (1)指向一个字符串常 ...
- Go基础---->go的基础学习(四)
这里简单的介绍一下go中的关于多线程的知识. Go中的多线程 一.go中简单的并发例子 package main import ( "fmt" "time" ) ...
- vue中npm install 报错之一
报错原因: 这是因为文件phantomjs-2.1.1-windows.zip过大,网络不好,容易下载失败 PhantomJS not found on PATH 解决方案一: 选择用cnpm ins ...
- weblogic jprofile配置
前提: 1.安装好weblogic 2.安装好jprofile 非等待模式: export JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.threadpo ...
- 【BZOJ4774/4006】修路/[JLOI2015]管道连接 斯坦纳树
[BZOJ4774]修路 Description 村子间的小路年久失修,为了保障村子之间的往来,法珞决定带领大家修路.对于边带权的无向图 G = (V, E),请选择一些边,使得1 <= i & ...
- 在CentOS中使用 yum 安装MongoDB及服务器端配置
转自 http://blog.csdn.net/zhangfeng19880710/article/details/20166853 一.准备工作: 运行yum命令查看MongoDB的包信息 [roo ...
- BeginnerAdmin后台框架的使用!
基于layui的后台框架,我比较喜欢使用BeginnerAdmin模板.但是在构建的时候可能会遇到一些问题. 问题一:侧栏出不来: 报错是这样的: 这个错误:说明的是 navbar.js没有引进来. ...