4. 数位和问题 为什么RE!!!!!!

#include<bits/stdc++.h>
using namespace std;
int top=0;
vector<int> b;
void push(int x){
  top++;
  b[top-1]=x;
}
void pop(){
  top--;
}
int main(){
  int n,q;
  cin>>n>>q;
  top=n;
  for(int i=0;i<top;i++){
    cin>>b[i];
  }
  int x,l,r;
  while(cin>>x){
    if(x==1){
      cin>>l>>r;
      for(int i=l-1;i<=r-1;i++){
        int sum=0;
        while(b[i]!=10){
          sum+=(b[i]%10);
          b[i]/=10;
        }
        b[i]=sum;
      }
    }
    else if(x==2){
      cin>>l;
      cout<<b[l-1]<<endl;
    }
  }
  return 0;
}