Advertisement
TLE

Untitled

TLE
Mar 10th, 2014
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <stdio.h>
  2. #include<stdlib.h>
  3.  
  4. int main()
  5. {
  6. long long n,m,s,t;
  7. int co,sum,carry;
  8. while( scanf("%lld %lld",&n,&m) == 2)
  9. {
  10. if(n == 0 && m == 0)
  11. {
  12. break;
  13. }
  14.  
  15. carry = 0;
  16. co = 0;
  17. for(; n%10 != 0 || m%10 != 0;)
  18. {
  19. s = n%10;
  20. t = m%10;
  21. sum = s + t + carry;
  22. n = n/10;
  23. m = m/10;
  24. if(sum<10)
  25. {
  26. carry = 0;
  27. continue;
  28. }
  29. else
  30. {
  31. co = co + 1 ;
  32. carry = sum/10;
  33. }
  34. }
  35.  
  36. if( co == 0)
  37. {
  38. printf("No carry operation.\n");
  39. }
  40. else if(co == 1)
  41. {
  42. printf("%d carry operation.\n",co);
  43. }
  44. else
  45. {
  46. printf("%d carry operations.\n",co);
  47. }
  48. }
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement