We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Loading...
  • Practice
  • Compete
  • Jobs
  • Leaderboard
  • Hiring developers?
  1. Practice
  2. Mathematics
  3. Fundamentals
  4. Jim and the Jokes
  5. Discussions

Jim and the Jokes

  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial

Sort 23 Discussions, By:

votes
  • recency
  • votes

Please Login in order to post a comment

  • ravitejas3 5 years ago+ 3 comments

    One of the Testcases(6) has 100000 elements with 12 31 in it. All same values. How can the output be 4999950000. Please explain.

    6|
    Permalink
    • MissKat 5 years ago+ 3 comments

      We can have two different events occur on the same date, which means all those events are considered separate events and not the same. Hope that helps. :)

      0|
      ParentPermalink
      • HackerGit 5 years ago+ 1 comment

        So for the following input 2 3 10 3 10 3 10 output should 3 right? or is it 6? If it is 3, shouldn't the output for the above mentioned test case be 4999850001?

        2|
        ParentPermalink
        • MissKat 5 years ago+ 0 comments

          Think of the first (3, 10) as A and second (3, 10) as B. We cannot make a joke with (A, A) because they are the same thing. (A, B) isn't though. :)

          -1|
          ParentPermalink
      • sticknanisha 4 years ago+ 2 comments

        How do you explain the second test case then?

        2

        2 25

        2 25

        Expected Answer: 0

        Shouldn't the expected answer be 1 following the logic of test case 6?

        1|
        ParentPermalink
        • sticknanisha 4 years ago+ 0 comments

          Nevermind, I misinterpreted this test case to mean that two events with the same day couldn't be used to make a joke (when it was actually trying to demonstrate a different constraint of the problem).

          2|
          ParentPermalink
        • xshanz 3 years ago+ 0 comments

          25 is not defined in base 2.. coz base 2 only have digits 0 or 1

          1|
          ParentPermalink
      • saurabhcse15 3 years ago+ 1 comment

        31 should be in invalid in base 12??

        1|
        ParentPermalink
        • kumarlee8299 2 years ago+ 0 comments

          nope not at all.split 31.that implies 3,1 here both 3 and 1 are less than or equal to 12.so 31 is valid in base 12

          1|
          ParentPermalink
    • johnwyz88 5 years ago+ 1 comment

      100000 choose 2 by the way = 4999950000

      2|
      ParentPermalink
      • HackerGit 5 years ago+ 1 comment

        But a joke with events (E1, E2) is same as a joke with events (E2, E1). So I was thinking the output should be 99999 choose 2.

        0|
        ParentPermalink
        • johnwyz88 5 years ago+ 0 comments

          (E1, E2) and (E2, E1) are the same. Just that there are 100000 of DIFFERENT events, not 99999.

          1|
          ParentPermalink
    • antonydoniya58 4 months ago+ 1 comment

      This tutorial on decimal and octal representation is very beneficial for students like me high waisted leather pants . We all know the importance of maths in our education system. This site helps the students to learn maths in a very interest way. All the doubts can be discussed here and hence can be solved. I loved the site very much.

      0|
      ParentPermalink
      • kumarlee8299 4 months ago+ 0 comments

        u gone nuts? check the site u have mentioned

        0|
        ParentPermalink
  • Tsukuyomi1 1 year ago+ 3 comments

    Python to the rescue...

    counts = [0]*100
    for i in range(int(input())):
        m,d = map(int,input().split())
        try:counts[int(str(d),m)]+=1
        except:pass
    print(sum(c*(c-1)//2 for c in counts))
    
    3|
    Permalink
    • aakalpa 1 year ago+ 0 comments
      • cool soln
      • counts = [0]*38 is enough since max=int('31',12)=37
      • also m,d=input().split() is enough
      1|
      ParentPermalink
    • AK103 2 months ago+ 0 comments
      [deleted]
      -1|
      ParentPermalink
    • dyxogus 6 days ago+ 0 comments

      I'd also put "except ValueError" here: ValueError is the only that can be raised and should be discarded (given that we discard invalid number relative to the base it's being converted to)

      0|
      ParentPermalink
  • campkev 3 years ago+ 0 comments

    The test case doesn't even get the joke right. Dates for the joke are 12/25 and 10/31

    3|
    Permalink
  • masterpradip 2 years ago+ 1 comment

    "The given numbers are all represented with digits from 0-9, that's why for months like 11 or 12, we can't use additional characters to represent 10 or 11."

    Can anyone explain this line to me with an example.

    2|
    Permalink
    • bennattj 2 years ago+ 1 comment

      I don't know what purpose that comment serves other than to confuse you. For November (11) and December (12), you would need digits other than 0-9 to represent some values. E.g. 11_{10} = A_{11} ('A' would represent 11 just as in hexadecimal). But there will never be a date like 11/A (since they only use digits 0-9).

      My advice: ignore this comment; it doesn't help you in any way unless there is some more clever way than how I solved the problem.

      0|
      ParentPermalink
      • warfreak2 4 months ago+ 0 comments

        A represents 10, B represents 11.

        0|
        ParentPermalink
  • [deleted] 3 years ago+ 1 comment

    Spoiler Alert *Three things to do*

    //here x=month and y=day
    
    1.check for invalid case
    x<=9&&(y%10>=x||(y/10)>=x)
    
    2.conversion to decimal for checking
    y%10+(y/10)*x //store result for every valid event
    
    3.sum_of_all(C(C-1)/2)
    C=no. of event having same value
    

    Most Welcome to Suggestions and Queries

    2|
    Permalink
    • vikasjha 2 years ago+ 0 comments

      why do you have x<=9 as an invalid case, shouldn't it be x<=1

      1|
      ParentPermalink
  • urosbojanic1 4 years ago+ 0 comments

    cin >> m >> d; x[i]=(d/10*m)+(d%10); if((d/10)>m || (d%10)>m){x[i]=0;} for(int j=0;j

    I'm getting timeout on cases 6-11, but I can't find a faster alg. Can someone help me?

    2|
    Permalink
  • DLo930 2 years ago+ 0 comments

    For everyone coding in Java: use long to pass test case 6

    1|
    Permalink
  • madhuvani 3 years ago+ 1 comment

    import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;

    public class Solution {

    public static void main(String[] args) {
            Scanner sc=new Scanner(System.in); 
        int n=sc.nextInt();
        int m[]=new int[n];
        int d[]=new int[n];
        int count=0;
        for(int i=0;i<n;i++){
            m[i]=sc.nextInt();
            d[i]=sc.nextInt();
    
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i!=j)
              {  if((d[i]%m[j]==d[j]%m[i]))
                    if((m[i]!=m[j]))
                    count++;
              }}
        }
        System.out.println(count/2);
    }
    

    }

    1|
    Permalink
    • avantikapatel77 3 years ago+ 0 comments

      can you please explain logic behind this?

      1|
      ParentPermalink
  • saikalyan2703 3 years ago+ 1 comment

    Please tell me what is wrong with my code. I got output for 6 testcases but failed failed for the last 5 testcases. I was not able to debug it.

    # Enter your code here. Read input from STDIN. Print output to STDOUT
    m=[]
    d=[]
    n=int(raw_input())
    if(n==1):
        print 0
        exit()
    for _ in range(n):
        x,y=raw_input().split(" ")
        m.append(int(x))
        d.append(y)
    
    o=[]    
    for i in range(len(m)):
        try:
            o.append(int(d[i],m[i]))
        except:
            continue
        
    if(len(set(o))==1):
        x=len(o)
        print int((x*(x-1))/2)
    else:
        x=len(o)-len(set(o))
        print int((x*(x-1))/2)
    
    1|
    Permalink
    • SahajR 3 years ago+ 1 comment

      You are not probably checking if the day of the month is valid. For example, the input 9 48 is invalid, as September does not have 48 days.

      0|
      ParentPermalink
      • vikasjha 2 years ago+ 0 comments

        The problem statement says that the provided events have a valid Gregorian Date

        1|
        ParentPermalink
  • kumarpritam863 9 months ago+ 0 comments

    what is wrong in this??

    int solve(vector> dates) { vector>base(13,vector(32)); long int count = 0; vectorcounter; counter.assign(38,0); for(int i = 0; i1) { count+=1; } } } } return count; }

    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature