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 ...
随机推荐
- java中定义一个CloneUtil 工具类
其实所有的java对象都可以具备克隆能力,只是因为在基础类Object中被设定成了一个保留方法(protected),要想真正拥有克隆的能力, 就需要实现Cloneable接口,重写clone方法.通 ...
- java中Date的使用情况
在开发中常使用情况. 1.将String转为date 例如"201604131630" //设置日期格式 public SimpleDateFormat sdf = new Si ...
- 第七篇:Logistic回归分类算法原理分析与代码实现
前言 本文将介绍机器学习分类算法中的Logistic回归分类算法并给出伪代码,Python代码实现. (说明:从本文开始,将接触到最优化算法相关的学习.旨在将这些最优化的算法用于训练出一个非线性的函数 ...
- web基础---->Fileupload文件的上传
这里我们介绍文件上传的知识,使用的是apache的Commons FileUpload框架. 文件上传的使用 项目的部分结构如下: 一.使用Commons FileUpload的上传功能,我们需要引入 ...
- devstack with neutron 参考文献
http://networkstatic.net/installing-openstack-ml2-neutron-plugin-devstack-fedora/ https://wiki.opens ...
- 学习Ruby你需要了解的相关知识(rvm, gem, bundle, rake, rails等)
这篇文章主要介绍了学习Ruby你需要了解的相关知识(rvm, gem, bundle, rake, rails等),需要的朋友可以参考下 Ruby 这个就不用多说了 RVM 用于帮你安装Rub ...
- Eclipse failed to get the required ADT version number from the sdk
failed to get the required ADT version number from the sdk 解决方法: eclipse 和 android studio 工具不能同时共用同一 ...
- 配置Python实战开发环境
一.安装Python和easy_install 和pip 新版本的linux下面应该带有这些环境,没有自带的话可以查找google配置. 二.配置python运行的虚拟化环境: 好处:Python的库 ...
- sql语句查询条件的不同表达方式对查询性能的影响
今天操作数据库遇到一个问题 目标表RA_AD_DAILY_DATA的数据量大概有5千万左右,其中的BUSINESS_DATE字段为日期类型 我要查询8月20号导入的三条记录,刚开始用这种方式去查: S ...
- (ubuntu ufw)My firewall is blocking network connections from the docker container to outside
Maybe this is due to the current version, but the current answer doesn't work on my system (Docker 0 ...