FunctionGame
Submit solution
Points:
10
Time limit:
5.0s
Memory limit:
256M
Author:
Problem type
Allowed languages
C#, Go, Java, Python
Implementa els mètodes (funcions) de la classe FunctionGame
.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
class FunctionGame {
// escriu el codi aqui
}
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
FunctionGame functionGame = new FunctionGame();
String functionName = scanner.next();
if("function1".equals(functionName)){
for (int i = 5; i-->0;) {
int param = scanner.nextInt();
int returnValue = functionGame.function1(param);
System.out.println(param + " -> " + returnValue);
}
} else if("function2".equals(functionName)){
for (int i = 5; i-->0;) {
int param = scanner.nextInt();
int returnValue = functionGame.function2(param);
System.out.println(param + " -> " + returnValue);
}
} else if("function3".equals(functionName)){
for (int i = 5; i-->0;) {
int param = scanner.nextInt();
int returnValue = functionGame.function3(param);
System.out.println(param + " -> " + returnValue);
}
} else if("function4".equals(functionName)){
for (int i = 5; i-->0;) {
int param = scanner.nextInt();
int returnValue = functionGame.function4(param);
System.out.println(param + " -> " + returnValue);
}
} else if("function5".equals(functionName)){
for (int i = 5; i-->0;) {
int param = scanner.nextInt();
int returnValue = functionGame.function5(param);
System.out.println(param + " -> " + returnValue);
}
} else if("function6".equals(functionName)){
for (int i = 5; i-->0;) {
int param1 = scanner.nextInt();
int param2 = scanner.nextInt();
int returnValue = functionGame.function6(param1, param2);
System.out.println(param1 + "," + param2 + " -> " + returnValue);
}
} else if("function7".equals(functionName)){
for (int i = 7; i-->0;) {
int param1 = scanner.nextInt();
int param2 = scanner.nextInt();
int returnValue = functionGame.function7(param1, param2);
System.out.println(param1 + "," + param2 + " -> " + returnValue);
}
} else if("function8".equals(functionName)){
for (int i = 7; i-->0;) {
int param1 = scanner.nextInt();
int param2 = scanner.nextInt();
int param3 = scanner.nextInt();
int returnValue = functionGame.function8(param1, param2, param3);
System.out.println(param1 + "," + param2 + "," + param3 + " -> " + returnValue);
}
}
}
}
Input Format
-
Constraints
-
Output Format
-
Test Case 1
Input
function1 1 2 3 5 10
Output
1 -> 2
2 -> 3
3 -> 4
5 -> 6
10 -> 11
Test Case 2
Input
function2 1 2 3 5 10
Output
1 -> -2
2 -> -1
3 -> 0
5 -> 2
10 -> 7
Test Case 3
Input
function3 1 2 3 5 10
Output
1 -> 10
2 -> 20
3 -> 30
5 -> 50
10 -> 100
Test Case 4
Input
function4 1 2 3 5 10
Output
1 -> 1
2 -> 3
3 -> 5
5 -> 9
10 -> 19
Test Case 5
Input
function5 1 2 3 5 10
Output
1 -> 6
2 -> 6
3 -> 6
5 -> 6
10 -> 6
Test Case 6
Input
function6 1 1 2 2 3 4 5 9 10 11
Output
1,1 -> 2
2,2 -> 4
3,4 -> 7
5,9 -> 14
10,11 -> 21
Test Case 7
Input
function7 1 2 3 4 7 5 8 5 11 8 5 5 3 3
Output
1,2 -> 2
3,4 -> 4
7,5 -> 7
8,5 -> 8
11,8 -> 11
5,5 -> 5
3,3 -> 3
Test Case 8
Input
function8 1 2 3 5 4 6 9 8 7 9 7 7 8 8 9 7 9 7 10 10 10
Output
1,2,3 -> 1
5,4,6 -> 4
9,8,7 -> 7
9,7,7 -> 7
8,8,9 -> 8
7,9,7 -> 7
10,10,10 -> 10
CC BY-NC-SA 4.0