(模拟)关于进制的瞎搞---You Are Given a Decimal String...(Educational Codeforces Round 70 (Rated for Div. 2))
题目链接: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))的更多相关文章
- 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 ...
- Educational Codeforces Round 63 (Rated for Div. 2) B. Game with Telephone Numbers 博弈思维+模拟+贪心思维
题意:博弈题面 给出一个数字序列 (>=11) 有两个人任意删除数字 直到 数字只剩下11位 如果删除后的数字串开头是8那么就是第一个赢 否则就是第二个人赢 第一个人先手 数字序列一定是奇 ...
- 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 ...
- Educational Codeforces Round 91 (Rated for Div. 2) C. Create The Teams (模拟)
题意:有\(n\)个队员,每个队友都有一个能力值,构造队伍,要求队伍人数*队伍中最低能力值不小于\(x\),求能构造的最大队伍数. 题解:大水题,排个序,倒着模拟就行了. 代码: int t; int ...
- 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] ...
- 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 ...
- Educational Codeforces Round 82 (Rated for Div. 2)D(模拟)
从低位到高位枚举,当前位没有就去高位找到有的将其一步步拆分,当前位多余的合并到更高一位 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h&g ...
- Educational Codeforces Round 80 (Rated for Div. 2)E(树状数组,模拟,思维)
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ],mx[],a[],pos[],sum ...
- Educational Codeforces Round 91 (Rated for Div. 2) A. Three Indices (模拟)
题意:有一长度为\(n\)的序列,问是否能找到\(a_{i}<a_{j},a_{j}>a_{k},(i<j<k)\),如果满足,输出其位置. 题解:直接暴力两头找即可,最坏复杂 ...
随机推荐
- docker自动启动容器
Docker提供了重新启动策略 来控制容器在退出时或Docker重新启动时是否自动启动.重新启动策略可确保以正确的顺序启动链接的容器.Docker建议您使用重新启动策略,并避免使用进程管理器来启动容器 ...
- R-ets()
前情需知 指数预测模型 指数模型是用来预测时序未来值的最常用模型.这类模型相对比较简单,但是实践证明它们的短期预测能力较好.不同指数模型建模时选用的因子可能不同.比如 单指数模型(simple/sin ...
- MS14-068提权
• Ms14- • 库 • https://github.com/bidord/pykek • ms14-.py -u user@lab.com -s userSID -d dc.lab.com • ...
- JS 浏览器地址栏传递参数,参数加密/解密(编码/解码)
我们有时候在JS里进行页面跳转,并且传递了参数(AppName),如下: window.location = "../../views/form/edit.html?AppName=新增&q ...
- C++的重载(overload)与重写(override)
C++的重载(overload)与重写(override) 成员函数被重载的特征:(同一层级类中来实现)(1)相同的范围(在同一个类中):(2)函数名字相同:名称和返回类型相同(3)参数不同:(4)v ...
- DL反向传播理解
作者:寒小阳 时间:2015年12月. 出处:http://blog.csdn.net/han_xiaoyang/article/details/50321873 声明:版权所有,转载请联系作者并注明 ...
- PHP JSON数据 AJAX
JSON数据的定义方式 //写入数据 var a = { code:"p001", name:"张三", shuzu:new Array(1,2,3,4), j ...
- leetcode-hard-array-238. Product of Array Except Self-NO
mycode 99.47% class Solution(object): def productExceptSelf(self, nums): """ :type ...
- Cortex-M3 异常返回值EXC_RETURN
[EXC_RETURN] 在进入异常服务程序后,硬件自动更新LR的值为特殊的EXC_RETURN.当程序从异常服务程序返回,把这个EXC_RETURN值送往PC时,就会启动处理器的异常中断返回序列.因 ...
- 小D课堂 - 新版本微服务springcloud+Docker教程_1_02技术选型
笔记 2.技术选型和学后水平 简介:课程所需基础和技术选型讲解,学完课程可以到达怎样的程度, 1.IDEA JDK8 Maven SpringBoot基础 Linux 2.理 ...