Topic Link
meaning of the questions: The first number to find positive integers (A, B), A, B is not greater than N, A is the last to meet a number of B
The first digital word, B A is the last digit, the digit is also considered, the number of positive integers satisfying the condition of the output
This problem has always been the feeling abc style
It was the first feeling is pure analog certainly huge trouble, to think there is no law, no rule found
And thinking about classified according to the number of bits.
Classified by the number of bits necessary to consider the number of bits inside the sub
It took some time organized into 9 ^ n are elements of the matrix (a symmetric matrix)
However, what is not, still have to find the remaining portion of N-10 ^ k
It goes back to the starting point
Trying to find the law from the 9 ^ n summation, to no avail
Trying to simplify analog or analog another angle, no avail
Read other people's answers, much the same
Again traversed N, N-dimensional array stored in the first number is i, j is the last digit of the number
Finally traversal ans [i] + = c [j] * c [j] [i]
#include<bits/stdc++.h>
using namespace std;
int n;
long long ans;
long long c[10][10];
int main()
{
//freopen("input.txt","r",stdin);
cin>>n;
for(int i=1;i<=n;i++)
{
string s=to_string(i);
c[s[0]-'0'][s[s.length()-1]-'0']++;
}
for(int i=0;i<10;i++)
for(int j=0;j<10;j++)
ans+=c[i][j]*c[j][i];
cout<<ans;
return 0;
}
Summary: I'm so weak ah