Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class P2 {
- public static void main(String[] args) throws IOException {
- // BufferedReader br = new BufferedReader(new InputStreamReader(new
- // FileInputStream("DATA20.txt")));
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- for (int h = 0; h < 5; h++) {
- String[] nums = br.readLine().split(" ");
- for (String s : nums) {
- int total = 0;
- boolean doubleNum = true;
- for (int i = s.length() - 1; i >= 0; i--) {
- int num = Integer.parseInt(s.charAt(i) + "");
- if (doubleNum) {
- if (num < 5) {
- // System.out.print(num * 2 + " ");
- total += num * 2;
- } else {
- // System.out.print((1 + 2 * (num - 5)) + " ");
- total += 1 + 2 * (num - 5);
- }
- } else {
- // System.out.print(num * 2 + " ");
- total += num;
- }
- doubleNum = !doubleNum;
- }
- // System.out.println();
- total %= 10;
- System.out.print((10 - total)%10);
- // System.out.println();
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement