-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a237600
Showing
105 changed files
with
2,119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
w, b = input().split() | ||
w = int(w) | ||
b = float(b) | ||
if (w % 5 == 0 and b>(w+.5)): | ||
b = b - w - 0.5 | ||
print('%.2f' % b) | ||
else: | ||
print('%.2f' % b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
T = int(input()) | ||
for tc in range(T): | ||
# Read integers a and b. | ||
(a, b) = map(int, input().split(' ')) | ||
|
||
ans = a + b | ||
print(ans) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
while True : | ||
n = int(input()) | ||
if n == 0 : | ||
break | ||
else : | ||
arr = input().split() | ||
check = True | ||
for i in range(n) : | ||
if int(arr[int(arr[i]) - 1]) != i + 1 : | ||
check = False | ||
if check : | ||
print('ambiguous') | ||
else : | ||
print('not ambiguous') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
|
||
int main() { | ||
int t; | ||
int n, m; | ||
cin >> t; | ||
while(t--) { | ||
cin >> n >> m; | ||
if(n>m) { | ||
cout<<">"<<endl; | ||
} | ||
if(n<m) { | ||
cout<<"<"<<endl; | ||
} | ||
if(n==m) { | ||
cout<<"="<<endl; | ||
} | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import java.util.*; | ||
|
||
class Codechef | ||
{ | ||
public static void main (String[] args) throws java.lang.Exception | ||
{ | ||
Scanner scan = new Scanner(System.in); | ||
if(scan.hasNext()){ | ||
int t=scan.nextInt(); | ||
for(int i=0;i<t;i++){ | ||
int A = scan.nextInt(); | ||
int B = scan.nextInt(); | ||
if(A>B){ | ||
System.out.println(">"); | ||
} | ||
else if(B>A){ | ||
System.out.println("<"); | ||
} | ||
else{ | ||
System.out.println('='); | ||
} | ||
} | ||
} | ||
scan.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
t = int(input()) | ||
|
||
while t: | ||
a, b = map(int, input().split(" ")) | ||
|
||
if a > b: | ||
print('>') | ||
elif a < b: | ||
print('<') | ||
else: | ||
print('=') | ||
|
||
t = t-1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include<stdio.h> | ||
|
||
int main() { | ||
|
||
int T, A, B; | ||
|
||
scanf("%d", &T); | ||
|
||
for(int i=1;i<=T;i++) { | ||
scanf("%d %d", &A, &B); | ||
if(A>B) { | ||
printf("%d %d\n", A, A+B); | ||
} | ||
else if(A<B) { | ||
printf("%d %d\n", B, A+B); | ||
} | ||
else if(A=B) { | ||
printf("%d %d\n", B, A+B); | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import java.util.*; | ||
|
||
class Codechef | ||
{ | ||
public static void main (String[] args) throws java.lang.Exception | ||
{ | ||
Scanner scan = new Scanner(System.in); | ||
int t = scan.nextInt(); | ||
while(t!=0){ | ||
int a = scan.nextInt(); | ||
int b = scan.nextInt(); | ||
if(a>b){ | ||
System.out.print(a); | ||
}else{ | ||
System.out.print(b); | ||
} | ||
System.out.println(" " + (a+b)); | ||
} | ||
scan.close(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
t = int(input()) | ||
|
||
while t: | ||
a, b = map(int, input().split(" ")) | ||
|
||
if a>b: | ||
print(a, a+b) | ||
elif a<b: | ||
print(b, a+b) | ||
else: | ||
print(a, b) | ||
|
||
t = t-1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main() { | ||
int t; | ||
cin >> t; | ||
|
||
while(t!=0) { | ||
int n; | ||
cin>>n; | ||
int k = 2048, s=0; | ||
for(int i=k;i>=1;i/=2) { | ||
s += n/i; | ||
n %= i; | ||
if(n==0) | ||
break; | ||
} | ||
cout<<s<<endl; | ||
t--; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <stdio.h> | ||
|
||
|
||
int gcd(int a,int b) { | ||
if(b==0) | ||
return a; | ||
else | ||
return gcd(b,a%b); | ||
} | ||
|
||
int main(void) { | ||
|
||
int t; | ||
scanf("%d", &t); | ||
while(t--) { | ||
|
||
int n; | ||
scanf("%d", &n); | ||
int a[50], i=0; | ||
|
||
for(i=0; i<n; i++) | ||
scanf("%d", &a[i]); | ||
int temp = gcd(a[0], a[1]); | ||
|
||
for(i=2; i<n; i++) { | ||
temp = gcd(temp, a[i]); | ||
} | ||
|
||
for(i=0; i<n; i++) { | ||
a[i] = a[i]/temp; | ||
printf("%d ", a[i]); | ||
} | ||
printf("\n"); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main() { | ||
int n; | ||
|
||
cin>> n; | ||
if(n%4==0) { | ||
cout<<n+1; | ||
} | ||
else { | ||
cout<<n-1; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import java.util.*; | ||
|
||
|
||
|
||
class Codechef { | ||
public static void main (String[] args) throws java.lang.Exception { | ||
Scanner scan = new Scanner(System.in); | ||
int n = scan.nextInt(); | ||
if(n%4 == 0) { | ||
n++; | ||
} else { | ||
n--; | ||
} | ||
System.out.println(n); | ||
scan.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
n = int(input()) | ||
|
||
if n%4 == 0: | ||
n = n+1 | ||
print(n) | ||
else: | ||
n = n-1 | ||
print(n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(n, k) = map(int, input().split(' ')) | ||
|
||
ans = 0 | ||
|
||
for i in range(n): | ||
x = int(input()) | ||
if x % k == 0: | ||
ans += 1 | ||
|
||
print(ans) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <stdio.h> | ||
|
||
int main() { | ||
// Read the number of test cases. | ||
int T; | ||
scanf("%d", &T); | ||
while (T>0) { | ||
// Read the input a, b | ||
int a, b; | ||
scanf("%d %d", &a, &b); | ||
|
||
// Compute the ans. | ||
// Complete the below line. | ||
int ans = a%b; | ||
printf("%d\n", ans); | ||
T--; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import java.util.Scanner; | ||
|
||
/* Name of the class has to be "Main" only if the class is public. */ | ||
class Codechef | ||
{ | ||
public static void main (String[] args) throws java.lang.Exception | ||
{ | ||
// your code goes here | ||
Scanner scan = new Scanner(System.in); | ||
int N = scan.nextInt(); | ||
|
||
for (int i=0; i<N; i++) | ||
{ | ||
int x = scan.nextInt(); | ||
int y = scan.nextInt(); | ||
System.out.println(x%y); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
n = int(input()) | ||
arr = [] | ||
|
||
for i in range(n): | ||
a, b = input().split() | ||
a = int(a) | ||
b = int(b) | ||
rem = a%b | ||
arr.append(rem) | ||
|
||
for i in range(n): | ||
print(arr[i]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <iostream.h> | ||
#include <math.h> | ||
using namespace std; | ||
int main() | ||
{ | ||
int t ; | ||
long n; | ||
cin >> t; | ||
while (t--) | ||
{ | ||
cin >> n; | ||
cout << int(sqrt(n)) << "\n"; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import java.util.*; | ||
|
||
/* Name of the class has to be "Main" only if the class is public. */ | ||
class Codechef | ||
{ | ||
public static void main (String[] args) throws java.lang.Exception | ||
{ | ||
Scanner scan = new Scanner(System.in); | ||
int t, n; | ||
double r = 1.0; | ||
t = scan.nextInt(); | ||
for(int i=0;i<t;i++) | ||
{ | ||
n = scan.nextInt(); | ||
r = Math.sqrt(n); | ||
n = (int)Math.floor(r); | ||
System.out.println(n); | ||
} | ||
scan.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# cook your dish here | ||
import math | ||
|
||
t = int(input()) | ||
|
||
for i in range(t): | ||
a = int(input()) | ||
sq = math.sqrt(a) | ||
print(int(sq)) |
Oops, something went wrong.