题目链接:https://codeforc.es/contest/1202/problem/B

题意:

给你一串数,问你插入最少多少数可以使x-y型机器(每次+x或+y的机器,机器每次只取最低位--%10)产生这个子序列。

解:

这题真的是。。。唉我真的,还是怪自己太弱吧,比如08888,8和前一个8相同的话你必须让机器输入东西(不能看着这串数反正都是一样就不输入)。

就是预处理x-y型每次加(0~9)最少需要多少次就行了,刚上蓝就rank1900+,以后多多磨练吧。

 #define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>//sprintf islower isupper
#include <cstdlib>//malloc exit strcat itoa system("cls")
#include <iostream>//pair
#include <fstream>
#include <bitset>
//#include <map>
//#include<unordered_map>
#include <vector>
#include <stack>
#include <set>
#include <string.h>//strstr substr
#include <string>
#include <time.h>//srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9;
#include <cmath>
#include <deque>
#include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less
#include <vector>//emplace_back
//#include <math.h>
//#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
#include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
#define fo(a,b,c) for(register int a=b;a<=c;++a)
#define fr(a,b,c) for(register int a=b;a>=c;--a)
#define mem(a,b) memset(a,b,sizeof(a))
#define pr printf
#define sc scanf
#define ls rt<<1
#define rs rt<<1|1
void swapp(int &a,int &b);
double fabss(double a);
int maxx(int a,int b);
int minn(int a,int b);
int Del_bit_1(int n);
int lowbit(int n);
int abss(int a);
//const long long INF=(1LL<<60);
const double E=2.718281828;
const double PI=acos(-1.0);
const int inf=(<<);
const double ESP=1e-;
const int mod=(int)1e9+;
const int N=(int)2e6+; char s[N];
int l; long long mp[][][],ans[][]; void work(int a,int b)//预处理
{
fo(i,,)
{
fo(j,,)
{
if(i==&&j==)//关键:因为不能什么都不输入;
continue;
mp[a][b][(a*i+b*j)%]=mp[b][a][(a*i+b*j)%]=min(mp[a][b][(a*i+b*j)%],(long long)i+j);
}
}
} void woo(int x,int y)//开始搞字符串;
{
fo(i,,l)
{
int tt=(s[i]-'')-(s[i-]-'');
tt+=;
tt%=;
if(mp[x][y][tt]==inf)
{
ans[x][y]=-;
break;
}
ans[x][y]+=mp[x][y][tt];
}
} int main()
{
s[]='';
fo(i,,)
fo(j,,)
fo(k,,)
mp[i][j][k]=inf;
fo(i,,)
{
fo(j,,)
work(i,j);
}
sc("%s",s+);
l=strlen(s)-;
fo(i,,)
{
fo(j,,)
{
woo(i,j);
}
}
fo(i,,)
{
fo(j,,)
{
if(ans[i][j]!=-)
ans[i][j]-=l-;//减去已经有的就行了;
long long temp=ans[i][j];
pr("%lld ",temp);
}
pr("\n");
}
return ;
} /**************************************************************************************/ int maxx(int a,int b)
{
return a>b?a:b;
} void swapp(int &a,int &b)
{
a^=b^=a^=b;
} int lowbit(int n)
{
return n&(-n);
} int Del_bit_1(int n)
{
return n&(n-);
} int abss(int a)
{
return a>?a:-a;
} double fabss(double a)
{
return a>?a:-a;
} int minn(int a,int b)
{
return a<b?a:b;
}

(模拟)关于进制的瞎搞---You Are Given a Decimal String...(Educational Codeforces Round 70 (Rated for Div. 2))的更多相关文章

  1. Educational Codeforces Round 33 (Rated for Div. 2) B. Beautiful Divisors【进制思维/打表】

    B. Beautiful Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  2. Educational Codeforces Round 63 (Rated for Div. 2) B. Game with Telephone Numbers 博弈思维+模拟+贪心思维

    题意:博弈题面  给出一个数字序列 (>=11)  有两个人任意删除数字 直到 数字只剩下11位 如果删除后的数字串开头是8那么就是第一个赢 否则就是第二个人赢 第一个人先手  数字序列一定是奇 ...

  3. Educational Codeforces Round 33 (Rated for Div. 2) A. Chess For Three【模拟/逻辑推理】

    A. Chess For Three time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  4. Educational Codeforces Round 91 (Rated for Div. 2) C. Create The Teams (模拟)

    题意:有\(n\)个队员,每个队友都有一个能力值,构造队伍,要求队伍人数*队伍中最低能力值不小于\(x\),求能构造的最大队伍数. 题解:大水题,排个序,倒着模拟就行了. 代码: int t; int ...

  5. Educational Codeforces Round 61 (Rated for Div. 2)D(二分,模拟,思维)

    #include<bits/stdc++.h>using namespace std;typedef long long ll;int n,k;ll a[200007],b[200007] ...

  6. Educational Codeforces Round 34 (Rated for Div. 2) B题【打怪模拟】

    B. The Modcrab Vova is again playing some computer game, now an RPG. In the game Vova's character re ...

  7. Educational Codeforces Round 82 (Rated for Div. 2)D(模拟)

    从低位到高位枚举,当前位没有就去高位找到有的将其一步步拆分,当前位多余的合并到更高一位 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h&g ...

  8. Educational Codeforces Round 80 (Rated for Div. 2)E(树状数组,模拟,思维)

    #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ],mx[],a[],pos[],sum ...

  9. Educational Codeforces Round 91 (Rated for Div. 2) A. Three Indices (模拟)

    题意:有一长度为\(n\)的序列,问是否能找到\(a_{i}<a_{j},a_{j}>a_{k},(i<j<k)\),如果满足,输出其位置. 题解:直接暴力两头找即可,最坏复杂 ...

随机推荐

  1. python多环境切换,pyenv的使用

    1.安装pyenv:https://github.com/pyenv/pyenv-installer curl -L https://github.com/pyenv/pyenv-installer/ ...

  2. vfprintf()函数

    函数声明:int vfprintf(FILE *stream, const char *format, va_list arg) 函数参数: stream—这是指向了FILE对象的指针,该FILE对象 ...

  3. AtCoder AGC031D A Sequence of Permutations (群论、置换快速幂)

    题目链接 https://atcoder.jp/contests/agc031/tasks/agc031_d 题解 这居然真的是个找规律神题... 首先要明白置换的一些基本定义,置换\(p\)和\(q ...

  4. 大体知道java语法2----------理解面向对象

    我参加过大大小小n场面试,被好几位面试官问到过:能不能谈谈面向对象的几大特征?什么是面向对象?对于这两个问题,我始终觉得一定要理解,其实不只是这种概念题(姑且算它是概念题吧),包括各种语法都应该去理解 ...

  5. 微信小程序_(组件)view视图容器

    微信小程序view组件官方文档 传送门 Learn 一.hover-class属性 二.hover-start-time与hover-stay-time属性 三.hover-stop-propagat ...

  6. Linux安装JDK、tomcat

    修改tomcat 相关配置必须重启后才生效 如何启动tomcat 在终端框内切换到tomcat 的bin路径下 启动tomcat:./startup.sh 关闭tomcat:./shutdown.sh ...

  7. 【Nginx】Linux 环境下 Nginx 配置SSL 证书

    一.解压三个包到相同目录编译nginx cd /usr/local/src/nginx-1.12.2 # 将下列的包版本号换成自己下载的版本号 ./configure --prefix=/usr/lo ...

  8. 快速查找 js 插件

    我们是否为一个插件找半天找不到而烦恼 BootCDN 现在不用了,我们可以在 https://www.bootcdn.cn/ 中查找我们想要的任何插件,然后点进去,一直到点进去文件,我们便可以得到 这 ...

  9. Nexus3.x帐号权限配置

    一.使用admin登录后,点击上方齿轮图标 二.打开左侧导航,Security Privileges:具体的权限明细,比如我创建一个test仓库,这里就会生成 Roles:添加角色,设置每个角色可看到 ...

  10. android data binding jetpack VI 清理一些概念。BR 运算表达式

    android data binding jetpack VIII BindingConversion android data binding jetpack VII @BindingAdapter ...