Simple problem. Just count it.
Code:
- /*************************************** **********************************
- * Copyright (c) 2008 by liukaipeng *
- * Liukaipeng at gmail dot com *
- **************************************** *********************************/
- /* @ Judge_id 00000 10035 C ++ "primary arithmatic "*/
- # Include <algorithm>
- # Include <cstdio>
- # Include <cstring>
- # Include <deque>
- # Include <fstream>
- # Include <iostream>
- # Include <list>
- # Include <map>
- # Include <queue>
- # Include <set>
- # Include <stack>
- # Include <string>
- # Include <vector>
- Using namespace STD;
- Int main (INT argc, char * argv [])
- {
- # Ifndef online_judge
- Freopen (string (argv [0]) + ". In"). c_str (), "r", stdin );
- Freopen (string (argv [0]) + ". Out"). c_str (), "W", stdout );
- # Endif
- Char const * msgs [] = {
- "No carry operation .",
- "1 carry operation .",
- "2 carry operations .",
- "3 carry operations .",
- "4 carry operations .",
- "5 carry operations .",
- "6 carry operations .",
- "7 carry operations .",
- "8 Carry operations .",
- "9 carry operations .",
- };
- Int A, B;
- While (scanf ("% d/N", & A, & B )&&! (A = 0 & B = 0 )){
- Int ncarries = 0;
- For (INT carry = 0 ;! (A = 0 & B = 0); A/= 10, B/= 10 ){
- Carry = (a % 10 + B % 10 + carry)/10;
- Ncarries + = carry;
- }
- Puts (MSGs [ncarries]);
- }
- Return 0;
- }