(模拟)关于进制的瞎搞---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)\),如果满足,输出其位置. 题解:直接暴力两头找即可,最坏复杂 ...
随机推荐
- Node.js 安装与开发
Node.js 简介 Node.js是一个Javascript运行环境(runtime),发布于2009年5月,由Ryan Dahl开发,实质是对Chrome V8引擎进行了封装.Node.js对一些 ...
- Remainder Problem
F. Remainder Problem 这个其实并不难,只是看看考察有没有分块的思路 思路:用一个ans[i][j]来记录所有k=(1~5e5)中所有a[k]%i==j的和,在查询的时候可以达到复杂 ...
- spring cloud stream整合
spring cloud stream整体架构核心概念图: 图一:消息的发送端和接收端可以是不同的中间件 图二: 图三:在消息的发送之前和消息的接收端套了一层管道 @Output:输出注释,用于定义发 ...
- [笔记]动态规划(dynamic programming)
动态规划与分治方法都是通过组合子问题的解来求解原问题,区别在于:分治方法将问题划分为互不相交的子问题,递归求解子问题,再将它们的解组合起来,求出原问题的解.分治算法可能反复的求解某些公共子问题,从而使 ...
- C++入门经典-例7.6-this指针,同一个类的不同对象数据
1:对于类的非静态成员,每个对象都有自己的一份拷贝,即每个对象都有自己的数据成员,不过成员函数却是每个对象共享的.那么调用共享的成员函数如何找到自己的数据成员呢?答案是通过类中隐藏的this指针. 2 ...
- Nginx事件管理之定时器事件
1. 缓存时间 1.1 管理 Nginx 中的每个进程都会单独地管理当前时间.ngx_time_t 结构体是缓存时间变量的类型: typedef struct { /* 格林威治时间1970年1月1日 ...
- jxbrowser java代码直接调用js代码
https://blog.csdn.net/shuaizai88/article/details/73743669 final Browser browser = new Browser(); Bro ...
- ubuntu下如何使得普通用户能够启动wireshark?
一. 将dumpcap的用户组更改为wireshark sudo chgrp wireshark /usr/bin/dumpcap 二. 设置其他用户也具有与root一样的权限来执行dumpcap s ...
- Node fs 创建多层文件夹
一.dirname()方法 1. 获得路径当中最后一段文件或文件夹所在的路径.多次调用path.dirname将会逐层返回上级目录 var path=require("path") ...
- java传递String参数
java传递String参数不会改变原String参数,此处传递的是copy package numCombine; public class NumComberAll { public static ...