Counting Perfect Subsequences

Sort by

recency

|

32 Discussions

|

  • + 0 comments

    Spent an hour trying to figure out what was wrong with my modDivide function... Noticed I was using ab += abc in main loop. Changed to a = (a + abc) % mod. Passed all test cases. ;_;

  • + 0 comments

    We can learn many things from this Editorial!!

  • + 1 comment

    Can someone please tell me in layman terms, why do we do power of (MOD-2) for calculating inverse function for n?

    #define MOD 1000000007
    
    long long InverseFunc(ll n){
      return pow(n,MOD-2);   
    }
    
  • + 2 comments

    My algorithm works with case 1 and simple cases found here in the discussion, where we can check by hand, but it fails with the test cases. For case 2, the solutions are: 67529287 67529287 441870358 916664717 834126565

    mine are: 239514543 239514543 865533985 125267162 652571787 Besides reading the editorial, is there another way to check?

    Example, these are some results for my algorithm:

    • aaaaaaaaaabbbbbbbbbb 184755
    • aaaaaaaaaabbbbbbbbbbcd 369511
    • aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd 134779297 (this also uses the mod)
  • + 2 comments

    The editorial for this one is awesome!