Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3.  
  4. ifstream cin("numere18.in");
  5. ofstream cout("numere18.out");
  6.  
  7. int main()
  8. {
  9. int c , n , m , s = 1 , i = 1 , s2 = 0;
  10.  
  11. cin >> c;
  12.  
  13. if(c == 1)
  14. {
  15. cin >> n;
  16.  
  17. while(i < n)
  18. {
  19. s = s + i;
  20. i++;
  21. }
  22. i = 0;
  23.  
  24. while(i < n)
  25. {
  26. s2 = s + i + s2;
  27. i++;
  28. }
  29.  
  30. cout << s2;
  31. }
  32. else
  33. {
  34. cin >> m;
  35.  
  36. while(s <= m)
  37. {
  38. s = s + i;
  39. i++;
  40. }
  41.  
  42. cout << i - 1 << " ";
  43. int f = 1;
  44. while(s > m)
  45. {
  46. s--;
  47. f++;
  48. }
  49. cout << i - f + 1;
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement