Advertisement
Korotkodul

N5. Формальный исполнитель

Nov 24th, 2021
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <set>
  5. #include <string>
  6. #include <algorithm>
  7. using namespace std;
  8. using ll = long long;
  9. void cv(vector <int> v){
  10. for (auto x: v) cout<<x<<' ';
  11. cout<<'\n';
  12. }
  13.  
  14. vector <int> ans;
  15. ll S(int n, int a1){
  16. //cout<<"(a1 + n - 1 ) * n = "<<(a1 + n - 1 ) * n<<'\n';
  17. //cout<<"a1= "<<a1<<" n= "<<n<<'\n';
  18. return (a1 + n - 1 ) * n;
  19. }
  20.  
  21. void al(ll N){
  22. int odd, evn;
  23. if (N % 2 == 0){
  24. odd = N-1;
  25. evn = N - 2;
  26. }else{
  27. odd = N - 2;
  28. evn = N - 1;
  29. }
  30. evn /= 2;
  31. odd = odd / 2 + 1;
  32. ll Sodd, Sevn;
  33. Sodd = S(odd,1);
  34. Sevn = S(evn,2);
  35. ll res = N - Sodd + Sevn;
  36. if (res == 67){
  37. ans.push_back(N);
  38. }
  39.  
  40. }
  41.  
  42. int main()
  43. {
  44. for (ll i=1;i<1e8;++i){
  45. //cout<<"i = "<<i<<'\n';
  46. al(i);
  47. }
  48. for (auto g: ans){
  49. cout<<g<<'\n';
  50. }
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement