Topic links: https://codeforc.es/contest/1202/problem/B
Meaning of the questions:
Number string you ask you can insert much xy minimum number of machine type ( each + x + y or machines, each machine taking only the least significant bit of - 10% ) to generate the sequence .
solution:
This question really are. . . Well I really do, or blame themselves too weak to it, such as a former 08888,8 and 8 the same, then you have to make the machine enter something ( can not look at this number string anyway, are not the same as the input ).
Xy is pre-shaped acceleration (0 to 9) requires a minimum number of times on the line every time, just the blue on rank1900 +, after a lot of temper it.
1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); 2 #include <cstdio>//sprintf islower isupper 3 #include <cstdlib>//malloc exit strcat itoa system("cls") 4 #include <iostream>//pair 5 #include <fstream> 6 #include <bitset> 7 //#include <map> 8 //#include<unordered_map> 9 #include <vector> 10 #include <stack> 11 #include <set> 12 #include <string.h>//strstr substr 13 #include <string> 14 #include <time.h>//srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9; 15 #include <cmath> 16 #include <deque> 17 #include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less 18 #include <vector>//emplace_back 19 //#include <math.h> 20 //#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor 21 #include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare) 22 using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation 23 #define fo(a,b,c) for(register int a=b;a<=c;++a) 24 #define fr(a,b,c) for(register int a=b;a>=c;--a) 25 #define mem(a,b) memset(a,b,sizeof(a)) 26 #define pr printf 27 #define sc scanf 28 #define ls rt<<1 29 #define rs rt<<1|1 30 void swapp(int &a,int &b); 31 double fabss(double a); 32 int maxx(int a,int b); 33 int minn(int a,int b); 34 int Del_bit_1(int n); 35 int lowbit(int n); 36 int abss(int a); 37 //const long long INF=(1LL<<60); 38 const double E=2.718281828; 39 const double PI=acos(-1.0); 40 const int inf=(1<<29); 41 const double ESP=1e-9; 42 const int mod=(int)1e9+7; 43 const int N=(int)2e6+10; 44 45 char s[N]; 46 int l; 47 48 long long mp[103][103][15], ANS [ 20 is ] [ 20 is ]; 49 50 void Work ( int A, int B) // preprocessing 51 is { 52 is FO (I, 0 , 100 ) 53 is { 54 is FO (J, 0 , 100 ) 55 { 56 is IF (I == 0 && J == 0 ) // key: nothing because they can not enter; 57 is Continue ; 58 MP [A] [B] [(A * B * I + J)% 10 ] MP = [B ] [A] [(A * B * I + J)% 10] = min (MP [A] [B] [(A * I + B * J)% 10 ], ( Long Long ) I + J); 59 } 60 } 61 is } 62 is 63 is void Woo ( int X, int Y) // start to engage the string; 64 { 65 FO (I, 2 , L) 66 { 67 int TT = (S [I] - ' 0 ' ) - (S [I- . 1 ] - ' 0 ' ); 68 TT + = 100 ; 69 TT% =10; 70 if(mp[x][y][tt]==inf) 71 { 72 ans[x][y]=-1; 73 break; 74 } 75 ans[x][y]+=mp[x][y][tt]; 76 } 77 } 78 79 int main() 80 { 81 s[0]='0'; 82 fo(i,0,13) 83 fo(j,0,13) 84 fo(k,0,13) 85 mp[i][j][k]=inf; 86 fo(i,0,9) 87 { 88 fo(j,0,9) 89 work(i,j); 90 } 91 sc("%s",s+1); 92 l=strlen(s)-1; 93 fo(i,0,9) 94 { 95 FO (J, 0 , . 9 ) 96 { 97 Woo (I, J); 98 } 99 } 100 FO (I, 0 , . 9 ) 101 { 102 FO (J, 0 , . 9 ) 103 { 104 IF (ANS [I] [J] = -! . 1 ) 105 ANS [I] [J] - L-= . 1 ; // subtracting already have on the line; 106 Long Long TEMP = ANS [I] [J]; 107 pr("%lld ",temp); 108 } 109 pr("\n"); 110 } 111 return 0; 112 } 113 114 /**************************************************************************************/ 115 116 int maxx(int a,int b) 117 { 118 return a>b?a:b; 119 } 120 121 void swapp(int &a,int &b) 122 { 123 a^=b^=a^=b; 124 } 125 126 int lowbit(int n) 127 { 128 return n&(-n); 129 } 130 131 int Del_bit_1(int n) 132 { 133 return n&(n-1); 134 } 135 136 int abss(int a) 137 { 138 return a>0?a:-a; 139 } 140 141 double fabss(double a) 142 { 143 return a>0?a:-a; 144 } 145 146 int minn(int a,int b) 147 { 148 return a<b?a:b; 149 }