Advertisement
TLE

10035

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