# Jim and the Jokes

# Jim and the Jokes

ravitejas3 + 2 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.

MissKat + 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. :)

HackerGit + 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?

MissKat + 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. :)

sticknanisha + 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?

sticknanisha + 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).

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

saurabhcse15 + 1 comment 31 should be in invalid in base 12??

kumarlee8299 + 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

johnwyz88 + 1 comment 100000 choose 2 by the way = 4999950000

Tsukuyomi1 + 1 comment 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))

aakalpa + 0 comments - cool soln
- counts = [0]*38 is enough since max=int('31',12)=37
- also m,d=input().split() is enough

masterpradip + 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.

bennattj + 0 comments 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.

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

[deleted] + 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**vikasjha + 0 comments why do you have x<=9 as an invalid case, shouldn't it be x<=1

urosbojanic1 + 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?

DLo930 + 0 comments For everyone coding in Java: use long to pass test case 6

madhuvani + 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); }`

}

avantikapatel77 + 0 comments can you please explain logic behind this?

saikalyan2703 + 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)

kumarpritam863 + 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; }

Sort 23 Discussions, By:

Please Login in order to post a comment