-
Notifications
You must be signed in to change notification settings - Fork 0
/
Count the ACs
37 lines (33 loc) · 1.04 KB
/
Count the ACs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Problem
There are 10 problems in a contest. You know that the score of each problem is either 1 or 100 points.
Chef came to know the total score of a participant and he is wondering how many problems were actually solved by that participant.
Given the total score P of the participant, determine the number of problems solved by the participant. Print −1 in case the score is invalid.
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* 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 sc=new Scanner(System.in);
int t=sc.nextInt();
for(int i=0;i<t;i++){
int a=sc.nextInt();
if(a<=10){
System.out.println(a);
}else{
int b=a/100;
int c=a%100;
if((b+c)<=10)
{
System.out.println(b+c);
}else
{
System.out.println(-1);
}
}
}// your code goes here
}
}