1. 

/**

* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10

 * Problem: 10035 Primary Arithmetic

* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=12&problem=976&mosmsg=Submission+received+with+ID+7967484

*

 * @author Viktoriya Ryabova

*

 * @version 1.0, 05/14/2010

*

 * Method : Ad-Hoc

* Status : Accepted

* Runtime: 0.924

*/

 

import java.util.Scanner;

 

public class Main {

 

      public static void main(String[] args) {

            // TODO Auto-generated method stub

            Scanner sc = new Scanner(System.in);

            long carry;

            int carryCount;

            long sum;

            while (sc.hasNext()) {

                  carry = 0;

                  carryCount = 0;

                  sum = 0;

                  //die zahlen einlesen

                  long a = sc.nextLong();

                  long b = sc.nextLong();

                  // falls beide sind nullen, wird die eingabe terminated

                  if (a == 0 && b == 0)

                        return;

                  while ( (a > 0) || (b >0)) {

                        //summe der letzten zeichen

                        sum = (carry + (a % 10) + (b % 10));

                        // falls die summe>=10, wird count  hochgezählt

                        if (sum >= 10) {

                             carryCount++;

                        }

                        //wird ausgerechnet, was genau carry betraegt

                        carry = sum/10;

                        //die zahlen werden auf letzte ziffer gekürtzt

                        a = a /10;

                        b = b /10;

                  }

                  if (carryCount == 0)

                        System.out.println("No carry operation.");

                  else if (carryCount == 1)

                        System.out.println("1 carry operation.");

                  else

                        System.out.println(carryCount + " carry operations.");
 

            }
 

      }

}

2.

/**
 * FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
 * Problem: 10035 - Primary Arithmetic
 * Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=976
 *
 * @author Evgeni Pavlidis
 * @version 1.0, 06/02/2010
 *
 * Method : Ad hoc
 * Status : Accepted
 * Runtime: 0.900
 */

import java.io.*;
import java.util.*;

class Main {

    public static void main(String...args)
    {
        Scanner sc = new Scanner(System.in);

        long a,b, carry = 0, c;

        while(true)
        {
            a = sc.nextLong();
            b = sc.nextLong();
            if(a == 0 && b == 0)
                break;

            c = 0;
            carry = 0;
            while(a > 0 || b > 0)
            {
                carry = (carry + (a%10) + (b%10)) / 10;
                //System.out.println(carry);
                if(carry > 0)
                    c++;
                a /= 10;
                b /= 10;
            }
           
            System.out.println(((c==0)? "No":c) + " carry operation" +((c>1)? "s.":"."));
        }
    }
}