You are not logged in. Please login at www.codechef.com to post your questions!

×

# plz help....getting WA.....:(

 0 I tried to figure out every test case covered .....but still getting wrong answer ....please point out my mistake .... this is the problem statement http://www.codechef.com/AUG13/problems/CHMOD my solution http://pastebin.com/m5q83MhQ asked 13 Aug '13, 01:41 15●12●21●24 accept rate: 0%

 2 vivek07671..in your code this statement is wrong.. if(left==right) { for(int i=1;i<=100;i++) { ans=(ans*fast_exp(i,a[left][i]))%mod; //Wrong statement } } Just try this input on your code 5 5 5 5 5 5 1 3 3 100 The answer should be 5 but your code will give 125... The correct statement is ans=(ans*fast_exp(i,a[left][i]-a[left-1)[i])%mod; answered 15 Aug '13, 13:00 678●9●16●26 accept rate: 9%
 0 Try this test case: 3 2 2 2 2 1 3 5 1 3 1000000  It give 1 6 whereas the actual output is 3 8. Hope it helps. answered 13 Aug '13, 23:27 3★sobhagya 2.7k●13●27●47 accept rate: 12%
 0 I am not getting the missed test case ....... #include #include #include using namespace std; long long int fast_exp(long long int ,long long int ); int a[100001][101]; long long int mod; int main() { int n; scanf("%d",&n); int temp; for(int i=0;i<=100000;i++) { for(int j=0;j<=100;j++) { a[i][j]=0; } } for(int i=1;i<=n;i++) { for(int j=1;j<=100;j++) a[i][j]=a[i][j]+a[i-1][j]; scanf("%d",&temp); a[i][temp]++; } int left,right; int t; scanf("%d",&t); long long int ans; long long int x; while(t--) { ans=1; scanf("%d",&left); scanf("%d",&right); scanf("%d",&mod); if(left==right) { for(int i=1;i<=100;i++) { ans=(ans*fast_exp(i,a[left][i]))%mod; //ans=ans%mod; } } else{ for(int i=1;i<=100;i++) { x=a[right][i]-a[left-1][i]; if(x>0) { ans=(ans*fast_exp(i,x))%mod; //ans=ans%mod; //cout<<"jhfdvbjfd"<0) { if(exp%2==1) res=(res*base)%mod; base=(base*base)%mod; exp/=2; } return res%mod; } /* 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 4 1 2 3 2 3 4 1 1 1 1 5 1000000000 */  answered 15 Aug '13, 01:26 15●12●21●24 accept rate: 0% 16.9k●49●115●225
 0 Try using scanf("%lld",&mod); instead of scanf("%d",&mod); The variable mod is declared as a long long int. answered 15 Aug '13, 08:20 4.2k●5●23●64 accept rate: 15%
 toggle preview community wiki:
Preview

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

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:

×1,070
×729
×47
×4
×1
×1

question asked: 13 Aug '13, 01:41

question was seen: 1,168 times

last updated: 15 Aug '13, 13:00