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

×

[closed] Help with the code of "help ram" problem code- aba14a

this is my C code which i wrote,but it is generating wrong answer error..can anyone please help me with any special case m missing:???????

code:-

    include<stdio.h>
    include<math.h>
    long long int prime(long long int); 
int main() { long long int t,tt,a,b,j=0,arr[100]; scanf("%lld",&t); if (t>100) return -1; tt=t; while(t--) { scanf("%lld%lld",&a,&b); if (a > b || a < 2) return -1; if(prime(b) && b!=a) arr[j++]=b-1; else if (prime(b) == 0) arr[j++]=b; else arr[j++]=-1; } for (j=0;j<tt;j++) printf("%lld\n",arr[j]); return 0; }

    long long int prime(long long int b) { int k=2,c; if (b==2) return 1; if (b==3) return 1; if (b%2==0) return 0; c=sqrt(b); //printf("%d\n",c); while(b%k!=0) { if (k==c) break; k++; } if (k == c) return 1; else return 0;

    }

asked 20 Mar '14, 19:17

mrigank's gravatar image

2★mrigank
1627
accept rate: 0%

closed 20 Mar '14, 19:54

vermashubhang's gravatar image

5★vermashubhang
1.5k11025

The question has been closed for the following reason "Duplicate Question" by vermashubhang 20 Mar '14, 19:54

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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:

×2,700
×1,470
×933
×646
×3

question asked: 20 Mar '14, 19:17

question was seen: 760 times

last updated: 20 Mar '14, 19:54