Investigation V Judge, Digit DP
Difference between en2 and en3, changed 24 character(s)
I need help in this problem. I have tried all the test cases on Udebug as well, they are passing. But Vjudge is not accepting my code.↵


~~~~~↵
//package DigitDp;↵


import java.io.IOException;↵
import java.util.ArrayList;↵
import java.util.HashMap;↵
import java.util.Scanner;↵

class Investigation {↵
    public static void main(String[] args)throws IOException {↵
        Scanner s=new Scanner(System.in);↵
        int test=s.nextInt();↵
        StringBuilder print=new StringBuilder();↵
        int c=1;↵
        while(test--!=0){↵
            print.append("Case "+c+": ");↵
            c++;↵
            char a[]=Integer.toString(s.nextInt()-1).toCharArray();↵
            char b[]=s.next().toCharArray();↵
            int m=s.nextInt();↵
            if(m>=100){↵
                print.append("0\n");↵
                continue;↵
            }↵
            int r=solve(b,m);↵
            int l=solve(a,m);↵
            int ans=r-l;↵
            print.append(ans+"\n");↵
        }↵
        System.out.println(print.toString());↵
    }↵
    public static int solve(char a[],int m){↵
        int n=a.length;↵
        HashMap<ArrayList<Integer>,Integer> map=new HashMap<>();↵
        ArrayList<Integer> temp=new ArrayList<>();↵
        temp.add(0);temp.add(0);temp.add(1);↵
        map.put(temp,1);↵
        for(int i=1;i<=n;i++){↵
            int cd=a[i-1]-48;↵
            HashMap<ArrayList<Integer>,Integer> curr=new HashMap<>();↵
            for(int p=0;p<=9;p++){↵
                for(ArrayList<Integer> t:map.keySet()){↵
                    int x=t.get(0);↵
                    int y=t.get(1);↵
                    int z=t.get(2);↵
                    int nx=(x*10+p)%m;↵
                    int ny=(y+p)%m;↵
                    int val=map.get(t);↵
                    if(p<cd){↵
                        ArrayList<Integer> te=new ArrayList<>();↵
                        te.add(nx);te.add(ny);te.add(0);↵
                        curr.put(te,curr.getOrDefault(te,0)+val);↵
                    }↵
                    else if(p==cd){↵
                        if(z==0){↵
                            ArrayList<Integer> te=new ArrayList<>();↵
                            te.add(nx);te.add(ny);te.add(0);↵
                            curr.put(te,curr.getOrDefault(te,0)+val);↵
                        }↵
                        if(z==1){↵
                            ArrayList<Integer> te2=new ArrayList<>();↵
                            te2.add(nx);te2.add(ny);te2.add(1);↵
                            curr.put(te2,curr.getOrDefault(te2,0)+val);↵
                        }↵
                    }↵
                    else{↵
                        if(z==0){↵
                            ArrayList<Integer> te=new ArrayList<>();↵
                            te.add(nx);te.add(ny);te.add(0);↵
                            curr.put(te,curr.getOrDefault(te,0)+val);↵
                        }↵
                    }↵
                }↵
            }↵
            map=curr;↵
        }↵
        int ans=0;↵
        for(ArrayList<Integer> t:map.keySet()){↵
            if(t.get(0)==0&&t.get(1)==0){↵
                ans+=map.get(t);↵
            }↵
        }↵
        return ans;↵
    }↵
}↵

~~~~~↵

Here's the problem  [Link](https://vjudge.net/problem/LightOJ-1068)↵

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English SLIMSHADYNICK 2020-07-27 09:01:20 8092
en3 English SLIMSHADYNICK 2020-07-27 06:32:11 24 Tiny change: 'n\n~~~~~\n//package DigitDp;\n\n\nimport j' -> 'n\n~~~~~\nimport j' (published)
en2 English SLIMSHADYNICK 2020-07-27 06:28:23 9 (saved to drafts)
en1 English SLIMSHADYNICK 2020-07-27 06:26:32 3306 Initial revision (published)