Skip to content

Commit 1f15e57

Browse files
authored
Add files via upload
1 parent 1f70420 commit 1f15e57

18 files changed

+371
-0
lines changed

(A) Anton and Danik.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+
import java.util.stream.IntStream;
3+
4+
public class Main {
5+
public static void main(String[] args) {
6+
Scanner sc = new Scanner(System.in);
7+
int n=sc.nextInt();
8+
String s=sc.next();
9+
int a=0;
10+
int b=0;
11+
for(int i=0;i<s.length();i++){
12+
if(s.charAt(i)=='A')
13+
a++;
14+
if(s.charAt(i)=='D')
15+
b++;
16+
}
17+
if(a>b)
18+
System.out.println("Anton");
19+
else if(a<b)
20+
System.out.println("Danik");
21+
else
22+
System.out.println("Friendship");
23+
}
24+
}

(A) Anton and Polyhedrons.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.Scanner;
2+
import java.util.stream.IntStream;
3+
4+
public class Main {
5+
public static void main(String[] args) {
6+
Scanner sc = new Scanner(System.in);
7+
int t=sc.nextInt();
8+
int ans=0;
9+
for(int q=0;q<t;q++){
10+
String s=sc.next();
11+
if(s.equals("Tetrahedron"))
12+
ans+= 4;
13+
else if(s.equals("Cube"))
14+
ans+= 6;
15+
else if(s.equals("Octahedron"))
16+
ans += 8;
17+
else if(s.equals("Dodecahedron"))
18+
ans += 12;
19+
else if(s.equals("Icosahedron"))
20+
ans += 20;
21+
22+
}
23+
System.out.println(ans);
24+
}
25+
}

(A) Bear and Big Brother.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import java.util.Scanner;
2+
import java.util.stream.IntStream;
3+
4+
public class Main {
5+
public static void main(String[] args) {
6+
Scanner sc = new Scanner(System.in);
7+
int limak=sc.nextInt();
8+
int bob=sc.nextInt();
9+
int year=0;
10+
while(limak<=bob){
11+
limak=limak*3;
12+
bob=bob*2;
13+
year++;
14+
}
15+
System.out.println(year);
16+
17+
}
18+
}

(A) Beautiful Matrix.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+
import java.util.stream.IntStream;
3+
4+
public class Main {
5+
public static void main(String[] args) {
6+
Scanner sc = new Scanner(System.in);
7+
char[][] matrix = new char[5][5];
8+
for (int i = 0; i < 5; i++)
9+
matrix[i] = sc.nextLine().replaceAll(" ", "").toCharArray();
10+
int R = -1, C = -1;
11+
for (int i = 0; i < 5; i++) {
12+
for (int j = 0; j < 5; j++) {
13+
if (matrix[i][j] == '1') {
14+
R = i;
15+
C = j;
16+
break;
17+
}
18+
}
19+
}
20+
int moves = Math.abs(R - 2) + Math.abs(C - 2);
21+
System.out.println(moves);
22+
23+
}
24+
}

(A) Bit++.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include<stdio.h>
2+
#include<string.h>
3+
4+
int main(){
5+
int n,x=0;
6+
scanf("%d\n",&n);
7+
char p[150];
8+
for(int i=0;i<n;i++){
9+
gets(p);
10+
if((p[0]=='-'&&p[1]=='-')||(p[1]=='-'&&p[2]=='-'))
11+
x--;
12+
if((p[0]=='+'&&p[1]=='+')||(p[1]=='+'&&p[2]=='+'))
13+
x++;
14+
}
15+
printf("%d\n",x);
16+
return 0;
17+
}

(A) Domino piling.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
{
5+
int n, m,ans;
6+
scanf("%d%d",&n,&m);
7+
ans=(m*n) / 2;
8+
printf("%d",ans);
9+
return 0;
10+
}

(A) Football.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
4+
int main(){
5+
char str[100];
6+
scanf("%s",&str);
7+
int count=1;
8+
for(int i=1;i<strlen(str);i++){
9+
if(str[i]==str[i-1]){
10+
count=count+1;
11+
if(count==7){
12+
printf("YES\n");
13+
return 0;
14+
}
15+
}
16+
else{
17+
count=1;
18+
}
19+
20+
}
21+
printf("NO\n");
22+
return 0;
23+
}

(A) Hulk.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+
import java.util.stream.IntStream;
3+
4+
public class Main {
5+
public static void main(String[] args) {
6+
Scanner sc = new Scanner(System.in);
7+
int n=sc.nextInt();
8+
for(int i=1;i<n;i++){
9+
if(i%2==1){
10+
System.out.print("I hate that ");
11+
}
12+
else{
13+
System.out.print("I love that ");
14+
}
15+
}
16+
if(n%2==1){
17+
System.out.print("I hate it");
18+
}
19+
if(n%2==0){
20+
System.out.print("I love it");
21+
}
22+
}
23+
}

(A) Mezo Playing Zoma.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import java.io.*;
2+
import java.math.*;
3+
import java.security.*;
4+
import java.text.*;
5+
import java.util.*;
6+
import java.util.concurrent.*;
7+
import java.util.regex.*;
8+
9+
public class zoma{
10+
public static void main(String[] args){
11+
Scanner sc=new Scanner(System.in);
12+
int n=sc.nextInt();
13+
String s=sc.next();
14+
int lcount=0;
15+
int rcount=0;
16+
int sum=0;
17+
for(int i=0;i<s.length();i++){
18+
if(s.charAt(i)=='L'){
19+
lcount++;
20+
}
21+
else{
22+
rcount++;
23+
}
24+
}
25+
sum=lcount+rcount+1;
26+
System.out.println(sum);
27+
}
28+
}

(A) Next Round.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import java.util.Scanner;
2+
public class problem158A
3+
{
4+
static Scanner sc=new Scanner(System.in);
5+
public static void main(String[] args)
6+
{
7+
int count=0;
8+
int[] score=new int[100];
9+
int n=sc.nextInt();
10+
int k=sc.nextInt();
11+
k=k-1;
12+
for(int i=0;i<n;i++){
13+
score[i]=sc.nextInt();
14+
}
15+
if(score[k]>0){
16+
for(int i=k+1;i<n&&score[k]==score[i];i++){
17+
count++;
18+
}
19+
System.out.println(count+k+1);
20+
}
21+
else{
22+
for(int i=0;i<k&&score[i]>0;i++){
23+
count++;
24+
}
25+
System.out.println(count);
26+
}
27+
}
28+
}

(A) Petya and Strings.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import java.io.*;
2+
import java.math.*;
3+
import java.security.*;
4+
import java.text.*;
5+
import java.util.*;
6+
import java.util.concurrent.*;
7+
import java.util.regex.*;
8+
9+
public class inter{
10+
public static void main(String[] args){
11+
Scanner sc=new Scanner(System.in);
12+
String s1=sc.next();
13+
String s2=sc.next();
14+
s1=s1.toLowerCase();
15+
s2=s2.toLowerCase();
16+
int flag=0;
17+
for(int i=0;i<s1.length();i++){
18+
if(s1.charAt(i)==s2.charAt(i))
19+
continue;
20+
else if(s1.charAt(i)<s2.charAt(i)){
21+
flag=-1;
22+
break;
23+
}
24+
else{
25+
flag=1;
26+
break;
27+
}
28+
}
29+
System.out.println(flag);
30+
}
31+
}

(A) String Task.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+
public class problem118A
3+
{
4+
public static void main(String[] args)
5+
{
6+
Scanner sc=new Scanner(System.in);
7+
char[] ch=new char[100];
8+
char[] v={'a','e','i','o','u','y'};
9+
String str=sc.next().toLowerCase().replaceAll("[aeiouyAEIOUY]","");
10+
StringBuilder s=new StringBuilder();
11+
for(int i=0;i<str.length();i++){
12+
s.append(".");
13+
s.append(str.charAt(i));
14+
}
15+
System.out.println(s);
16+
}
17+
}

(A) Team.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <stdio.h>
2+
3+
int main(){
4+
int t;
5+
scanf("%d",&t);
6+
int count=0;
7+
for(int q=0;q<t;q++){
8+
int a[3];
9+
for(int i=0;i<3;i++){
10+
scanf("%d",&a[i]);
11+
}
12+
if((a[0]+a[1]+a[2])>=2){
13+
count++;
14+
}
15+
16+
}
17+
printf("%d",count);
18+
return 0;
19+
}

(A) Theatre Square.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import java.util.Scanner;
2+
public class problem1A
3+
{
4+
public static void main(String[] args)
5+
{
6+
Scanner sc=new Scanner(System.in);
7+
double n=sc.nextInt();
8+
double m=sc.nextInt();
9+
double a=sc.nextInt();
10+
System.out.println((long)(Math.ceil(n/a)*Math.ceil(m/a)));
11+
}
12+
}

(A) Three Friends.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+
import java.util.stream.IntStream;
3+
4+
public class Main {
5+
public static void main(String[] args) {
6+
Scanner sc = new Scanner(System.in);
7+
8+
int q = sc.nextInt();
9+
for (int tc = 0; tc < q; tc++) {
10+
int a = sc.nextInt();
11+
int b = sc.nextInt();
12+
int c = sc.nextInt();
13+
14+
System.out.println(solve(a, b, c));
15+
}
16+
17+
sc.close();
18+
}
19+
20+
static int solve(int a, int b, int c) {
21+
return Math.max(0, IntStream.of(a, b, c).max().getAsInt() - IntStream.of(a, b, c).min().getAsInt() - 2) * 2;
22+
}
23+
}

(A) Watermelon.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import java.util.Scanner;
2+
public class Problem4A{
3+
static Scanner sc=new Scanner(System.in);
4+
public static void main(String args[]){
5+
int weight=sc.nextInt();
6+
if(weight>2&&weight%2==0)
7+
System.out.println("YES");
8+
else
9+
System.out.println("NO");
10+
}
11+
}

(A) Way Too Long Words.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+
public class problem71A
3+
{
4+
static Scanner sc=new Scanner(System.in);
5+
public static void main(String[] args)
6+
{
7+
double length=sc.nextInt();
8+
String str=null;
9+
for(int i=0;i<=length;i++){
10+
str=sc.nextLine();
11+
if(str.length()>10){
12+
System.out.print(str.charAt(0));
13+
System.out.print(str.length()-2);
14+
System.out.println(str.charAt(str.length()-1));
15+
}
16+
else
17+
System.out.println(str);
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)