Skip to content

Commit 697aee1

Browse files
committed
CodeChef Problem
1 parent ecf121e commit 697aee1

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

CODECHEF/CODECHEF_MAXCOUNT.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//CodeChef Problem : Count Of Maximum(Peer)
2+
//Problem Code : MAXCOUNT
3+
//Author: Piyush
4+
#include<stdio.h>
5+
int main()
6+
{
7+
int t,n,no[10001],i,j,l,val;
8+
scanf("%d",&t);
9+
while(t--)
10+
{
11+
scanf("%d",&n);
12+
for(i=0;i<10001;i++)
13+
{
14+
no[i]=0;
15+
}
16+
for(i=1;i<=n;i++)
17+
{
18+
scanf("%d",&j);
19+
++no[j];
20+
}
21+
l=0;
22+
for(i=1;i<10001;i++)
23+
{
24+
if(no[i]>l)
25+
{
26+
l=no[i];
27+
val=i;
28+
}
29+
}
30+
printf("%d %d\n",val,l);
31+
}
32+
return 0;
33+
}

CODECHEF/CODECHEF_PRPALIN.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//CodeChef Problem : Prime Palindromes(Peer)
2+
//Problem Code:PRPALIN
3+
//Author : Piyush
4+
#include<stdio.h>
5+
int rev(int);
6+
int prime(int);
7+
int main()
8+
{
9+
int no,i,p,r;
10+
scanf("%d",&no);
11+
while(no<=1000000)
12+
{
13+
p=prime(no);
14+
r=rev(no);
15+
if(p==0 && r==0)
16+
{
17+
printf("%d\n",no);
18+
break;
19+
}
20+
no++;
21+
}
22+
return 0;
23+
}
24+
int prime(int no)
25+
{
26+
int i;
27+
for(i=2;i<no;i++)
28+
{
29+
if(no%i==0)
30+
return 1;
31+
}
32+
return 0;
33+
}
34+
int rev(int no)
35+
{
36+
int re=0,p=no;
37+
while(no)
38+
{
39+
re=(re*10)+(no%10);
40+
no/=10;
41+
}
42+
if(re==p)
43+
return 0;
44+
else
45+
return 1;
46+
}

0 commit comments

Comments
 (0)