[Lanqiao Cup 2023 Country B] Sub 2023
Question A: Sub-2023
【Problem Description】
Xiaolan writes down 1 1 continuously on the blackboard1 to2023 2023For all integers between 2023 , a number sequence is obtained:
S = 12345678910111213 ⋯ 20222023 S = 12345678910111213\cdots 20222023S=12345678910111213⋯20222023Xiaolan
wants to knowSSHow many seed sequences in S are exactly equal to 2023 20232023?
Tip, the following are 3 33 types of subsequences that meet the conditions (the numbers identified in square brackets are the numbers contained in the subsequence):
1 [ 2 ] 34567891 [ 0 ] 111 [ 2 ] 1 [ 3 ] 14151617181920212223 ⋯ 1[\textbf2]34567891[\textbf0]111[\textbf2]1[\textbf3]14151617181920212223 \cdots1[2]34567891[0]111[2]1[3]14151617181920212223⋯
1 [ 2 ] 34567891 [ 0 ] 111 [ 2 ] 131415161718192021222 [ 3 ] ⋯ 1[\textbf2]34567891[\textbf0]111[\textbf2]131415161718192021222[\textbf3] \cdots1[2]34567891[0]111[2]131415161718192021222[3]⋯
1 [ 2 ] 34567891 [ 0 ] 111213141516171819 [ 2 ] 021222 [ 3 ] ⋯ 1[\textbf2]34567891[\textbf0]111213141516171819[\textbf3] \cdots1[2]34567891[0]111213141516171819[2]021222[3]⋯
Note that the following is a subsequence that does not meet the conditions, although it contains2 22、 0 0 0、 2 2 2、 3 3 3 four numbers, but the order is wrong:
1 [ 2 ] 345678910111 [ 2 ] 131415161718192 [ 0 ] 21222 [ 3 ] ⋯ 1[\textbf2]345678910111[\textbf2]131415161718192[\textbf0]21222[ \textbf3] \cdots1[2]345678910111[2]131415161718192[0]21222[3]⋯
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
string s;
for(int i=1;i<=2023;i++) s+=to_string(i);
LL a=0;//2 de data
LL b=0;//20 de data
LL c=0;//202 de data
LL d=0;//2023 de data
for(int i=0;i<s.size();i++)
{
if(s[i]=='2')
{
a++;
c+=b;
}
if(s[i]=='0') b+=a;
if(s[i]=='3') d+=c;
}
cout<<d;//5484660609
return 0;
}