Official
B - Measure Editorial by en_translator
To answer this problem correctly, find \(S_i\) for each \(i = 0, 1, 2, \ldots, N\) just as instructed in the problem statement to construct the sought string \(s_0s_1\ldots s_N\).
One can perform an operation for each \(i = 0, 1, 2, \ldots, N\), and inspect each integer between \(1\) and \(9\) as a candidate of \(j\), with a loop feature (like a for statement) which is a standard feature of a programming language.
The following is a sample code in C++ language.
#include <iostream>
using namespace std;
int main(void)
{
int n;
cin >> n;
string s;
for(int i = 0; i <= n; i++){
s += "-";
for(int j = 1; j <= 9; j++){
if(n % j == 0 && i % (n/j) == 0){
s[i] = j + '0';
break;
}
}
}
cout << s << endl;
return 0;
}
posted:
last update: