#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
void fre() { freopen("A.txt","r",stdin), freopen("Ans.txt","w",stdout); }
#define ll long long
int main()
{
/* fre(); */
int n, k;
cin >> n >> k;
string s;
cin >> s;
string str;
for(int i = 0; i < k; i ++)
str += s[i];
for(int i = k; i < n; i ++)
str += str[i - k];
if(str >= s)
{
cout << n << endl << str << endl;
}
else
{
for(int i = k - 1; i >= 0; i --)
{
if(str[i] != ‘9‘)
{
str[i] ++;
break;
}
else
str[i] = ‘0‘;
}
for(int i = k; i < n; i ++)
str[i] = str[i - k];
cout << n << endl << str << endl;
}
return 0;
}
G - Long Beautiful Integer CodeForces - 1268A(贪心)
原文:https://www.cnblogs.com/lql-nyist/p/12732907.html