c++ code error checking

There is sequence 1, 12, 123, 1234, ..., 12345678910, ... . Given first N elements of that sequence. You must determine amount of numbers in it that are divisible by 3. include using namespace std; int main() { long long int N,sum=1,count=0; cin>>N; long long int a[N];/maybe this data type can cause problem but i changed nothing changed./ for (int i=0;i

May 4, 2025 - 14:07
 0
c++ code error checking

There is sequence 1, 12, 123, 1234, ..., 12345678910, ... . Given first N elements of that sequence. You must determine amount of numbers in it that are divisible by 3.

include

using namespace std;
int main() {
long long int N,sum=1,count=0;
cin>>N;
long long int a[N];/maybe this data type can cause problem but i changed nothing changed./
for (int i=0;i a[i]=sum;
sum=sum*10+(i+2);
if (a[i]%3==0)
count++;
}
cout<

return 0;

}
what is my mistake in this code. It fits till 7th test