fork download
  1. #include <iostream>
  2. #define ll long long
  3. using namespace std;
  4. const int NN=2207;
  5. const int mod=998244353;
  6. int n,m,i,j,dp[NN][NN],a[NN][NN],x;
  7. int main() {
  8. ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  9. cin >> n >> m;
  10. for (i=1;i<=n;i++)
  11. {
  12. cin >> x;
  13. j=m;
  14. for (j=m;j>=1;j--)
  15. {
  16. a[i][j]=x%10;
  17. x=x/10;
  18. };
  19. };
  20. for (i=1;i<=n;i++)
  21. for (j=1;j<=m;j++)
  22. {
  23. dp[i][j]=(dp[i-1][j]+dp[i-1][j-1]+dp[i][j-1]+a[i][j])%mod;
  24. cout << dp[i][j] << " " << i << " " << j << endl;
  25. }
  26. cout << dp[n][m]+a[1][1]*2+a[n][m]*2;
  27. }
Success #stdin #stdout 0s 5312KB
stdin
2 2
22
07
stdout
2 1 1
4 1 2
2 2 1
15 2 2
33