Advertisement
cupsamada

POINTLAND versiune finala

Jan 14th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<climits>
  4. using namespace std;
  5. ifstream fin("pointland.in");
  6. ofstream fout("pointland.out");
  7. int j[1005];
  8. int main()
  9. {
  10. int x10=0, y10=0, nrc=0, nrcif=0, cifra, t, v, c=0, i;
  11. long long xpl, aux2, aux3, aux, aux1, n1, n2, rez, r;
  12. char op;
  13. fin>>v;
  14. if(v==1)
  15. {
  16. fin>>xpl;
  17. aux=xpl;
  18. do
  19. {
  20. nrcif++;
  21. aux=aux/10;
  22. }
  23. while(aux!=0);
  24. aux1=xpl;
  25. for(i=1; i<=nrcif; i++)
  26. {
  27. cifra=aux1%10;
  28. t=i*(i+1)/2;
  29. x10=x10+cifra*t;
  30. aux1=aux1/10;
  31.  
  32. }
  33. fout<<x10;
  34.  
  35. }
  36. if(v==2)
  37. {
  38. fin>>n1>>op>>n2;
  39. aux=n1;
  40.  
  41. do
  42. {
  43. nrcif++;
  44. aux=aux/10;
  45. }while(aux!=0);
  46.  
  47. aux1=n1;
  48.  
  49. for(i=1; i<=nrcif; i++)
  50. {
  51. cifra=aux1%10;
  52. t=i*(i+1)/2;
  53. x10=x10+cifra*t;
  54. aux1=aux1/10;
  55.  
  56. }
  57.  
  58. aux2=n2;
  59.  
  60. do
  61. {
  62. nrc++;
  63. aux2=aux2/10;
  64. }while(aux2!=0);
  65.  
  66. aux3=n2;
  67.  
  68. for(i=1; i<=nrc; i++)
  69. {
  70. cifra=aux3%10;
  71. t=i*(i+1)/2;
  72. y10=y10+cifra*t;
  73. aux3=aux3/10;
  74. }
  75.  
  76. if(op=='+')
  77. {
  78. rez=x10+y10;
  79. }
  80. if(op=='-')
  81. {
  82. rez=x10-y10;
  83. }
  84. if(op=='*')
  85. {
  86. rez=x10*y10;
  87. }
  88. if(op=='/')
  89. {
  90. rez=x10/y10;
  91. }
  92. int l=0; fout<<rez<<endl;
  93. for(i=1; i<=INT_MAX; i++)
  94. {
  95. if(aux+i+1<=rez)
  96. {
  97. l++;
  98. j[i]=i*(i+1)/2;
  99. aux=j[i];
  100. }
  101. else
  102. {
  103. break;
  104. }
  105. }
  106. /* for(i=l; i>=1; i--)
  107. {
  108. vec=v[i];
  109. while(rez-vec>0)
  110. {
  111. c++;
  112. }
  113. fout<<c;
  114. }*/
  115. }
  116. if(v==3)
  117. {
  118. fin>>xpl;
  119. aux=xpl;
  120. do
  121. {
  122. nrcif++;
  123. aux=aux/10;
  124. }while(aux);
  125. t=nrcif*(nrcif+1)/2;
  126. fout<<t;
  127. }
  128. fin.close();
  129. fout.close();
  130.  
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement