Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c2a2778

Browse files
Added all Competitive Programming Codes
1 parent 961484d commit c2a2778

File tree

147 files changed

+2376
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+2376
-1
lines changed

‎Codechef/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## This repository contains codes for codechef problems
2+
3+
#### @author: Saurav Jaiswal(sauravjaiswalsj.github.io)

‎Codechef/beg/.Guddu.java.swp

12 KB
Binary file not shown.

‎Codechef/beg/.SmallFactorials.java.swp

12 KB
Binary file not shown.

‎Codechef/beg/AddNumber.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import java.util.Scanner;
2+
class AddNumeber{
3+
public static void main(String[] args){
4+
Scanner cin=new Scanner(System.in);
5+
int t=cin.nextInt();
6+
while(t!=0){
7+
int a=cin.nextInt();
8+
int b=cin.nextInt();
9+
System.out.println(a+b);
10+
t--;
11+
}
12+
}
13+
}

‎Codechef/beg/Addfstnlst.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import java.util.Scanner;
2+
3+
class Addfstnlst{
4+
public static void main(String[] args){
5+
Scanner cin=new Scanner(System.in);
6+
int t=cin.nextInt();
7+
while(t!=0){
8+
long num=cin.nextLong();
9+
System.out.println(addDigit(num));
10+
t--;
11+
}
12+
}
13+
public static long addDigit(long num){
14+
int sum=0,fst=0;
15+
int lst=(int)num%10;
16+
while(num!=0){
17+
if(num<10 && num>0){
18+
fst=(int)num;
19+
}
20+
num/=10;
21+
}
22+
return lst+fst;
23+
}
24+
}

‎Codechef/beg/BankAtm.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import java.util.Scanner;
2+
import java.text.DecimalFormat;
3+
class BankAtm{
4+
public static final Scanner cin=new Scanner(System.in);
5+
public static final DecimalFormat df=new DecimalFormat("#0.00");
6+
public static void main(String[] args){
7+
int amount=cin.nextInt();
8+
double balance=cin.nextDouble();
9+
if(amount%5==0 && amount<=balance-0.5){
10+
double bal=balance-(double)amount-0.50;
11+
System.out.println(df.format(bal));
12+
}else{
13+
System.out.println(df.format(balance));
14+
}
15+
}
16+
}
17+

‎Codechef/beg/EnormousInputTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import java.util.Scanner;
2+
class EnormousInputTest{
3+
public static void main(String[] args){
4+
Scanner cin=new Scanner(System.in);
5+
int n=cin.nextInt();
6+
int k=cin.nextInt();
7+
long[] num=new long[n];
8+
for(int i=0;i<n;i++){
9+
num[i]=cin.nextLong();
10+
}
11+
int count=0;
12+
for(int i=0;i<n;i++){
13+
if(num[i]%k==0){
14+
count++;
15+
}
16+
}
17+
System.out.println(count);
18+
}// main ends
19+
}//class ends
20+

‎Codechef/beg/FindRem.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import java.util.Scanner;
2+
class FindRem{
3+
public static void main(String[] args){
4+
Scanner cin=new Scanner(System.in);
5+
int t=cin.nextInt();
6+
while(t!=0){
7+
int a=cin.nextInt();
8+
int b=cin.nextInt();
9+
System.out.println(a%b);
10+
t--;
11+
}
12+
}
13+
}

‎Codechef/beg/LuckyFour.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import java.util.Scanner;
2+
3+
class LuckyFour{
4+
public static void main(String[] agrs){
5+
Scanner cin=new Scanner(System.in);
6+
int t=cin.nextInt();
7+
while(t!=0){
8+
long n=cin.nextLong();
9+
System.out.println(getCount(n));
10+
t--;
11+
}
12+
13+
}
14+
public static int getCount(long n){
15+
int count=0;
16+
while(n!=0){
17+
int rem=(int)n%10;
18+
if(rem==4){
19+
count++;
20+
}n/=10;
21+
}
22+
return count;
23+
}
24+
}

‎Codechef/beg/ReverseNumber.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import java.util.Scanner;
2+
3+
class ReverseNumber{
4+
public static final Scanner cin=new Scanner(System.in);
5+
public static void main(String[] args){
6+
int t=cin.nextInt();
7+
int num,rvalue;
8+
while(t!=0){
9+
num=cin.nextInt();
10+
System.out.println(reverse(num));
11+
}
12+
}
13+
public static int reverse(int num){
14+
int sum=0;
15+
while(num!=0){
16+
int rem=num%10;
17+
sum=sum*10+rem;
18+
num/=10;
19+
}
20+
return sum;
21+
}
22+
}
23+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /