×

# Help me with my code for WITMATH

 0 I submitted my code in python of WITMATH during the contest and got AC. When i was submitting the same using C++ it was giving TLE though i had taken all steps to prevent overflow. Please can anyone help. Here's my code: /*aayushagarwal*/ #include #include using namespace std; unsigned long long int mult(unsigned long long int a,unsigned long long int b,unsigned long long int c) { unsigned long long int x=0,y=a%c; while(b>0) { if(b%2==1) {x=x+y; if(x>c)x=x%c; } y=y+y; if(y>c)y=y%c; b/=2; } return x%c; } unsigned long long int modulo( unsigned long long int a, unsigned long long int b, unsigned long long int c) { unsigned long long int x = 1; unsigned long long int y = a; while (b>0) { if (b%2==1) x = mult(x,y,c); y = mult(y,y,c); b = b/2; } return x%c; } bool millerRabin(unsigned long long int N,unsigned long long int iteration) { if (N<2) return false; if (N!=2&&N%2==0) return false; unsigned long long int d=N-1; while (d%2==0) d = d/2; for (long long int i=0;i

 0 Kindly post your question on the editorial page of the respective problem here: http://discuss.codechef.com/questions/9723/witmath-editorial. You will get your answer to your query. answered 15 May '13, 19:26 0★admin ♦♦ 19.8k●350●498●541 accept rate: 36%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×16

question asked: 15 May '13, 19:04

question was seen: 825 times

last updated: 17 May '13, 16:36