Advertisement
lalalalalalalaalalla

Untitled

Jul 7th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <iomanip>
  5. #include <queue>
  6. #include <cmath>
  7. #include <algorithm>
  8. #include <tuple>
  9. #include <iomanip>
  10. #include <stdio.h>
  11. #include <numeric>
  12. #include <map>
  13. #include <math.h>
  14. #include <bitset>
  15.  
  16. #define int long long
  17. #define ull unsigned long long
  18. #define all(a) a.begin(), a.end()
  19. #define pii pair<int, int>
  20. #define pb push_back
  21.  
  22. using namespace std;
  23.  
  24. const double PI = 3.14159265358;
  25.  
  26. long long gcd(long long a, long long b) {
  27. if (a==0) return b;
  28. if (b==0) return a;
  29. if (a>b) return gcd(a%b,b); else return gcd(b%a,a);
  30. }
  31. int prime(int p) {
  32. for (int i=2;i*i<=p;i++) {
  33. if (p%i==0 && i<p) return 0;
  34. }
  35. return 1;
  36. }
  37.  
  38. double s(int x1, int y1, int x2, int y2) {
  39. return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  40. }
  41.  
  42. char w(char r){
  43. if (r == '0') return '1';
  44. if (r == '1') return '2';
  45. if (r == '2') return '3';
  46. if (r == '3') return '4';
  47. if (r == '4') return '5';
  48. if (r == '5') return '6';
  49. if (r == '6') return '7';
  50. if (r == '7') return '8';
  51. if (r == '8') return '9';
  52. return '0';
  53. }
  54.  
  55. string t(string s) {
  56. reverse(all(s));
  57. if (s[0] - '0' >= 5) {
  58. // cout << "here\n";
  59. s[1] = w(s[1]);
  60. // cout << s[1] << "\n";
  61. int ind = 1;
  62. while (s[ind] == '0') {
  63. ind++;
  64. s[ind] = w(s[ind]);
  65. }
  66. }
  67. reverse(all(s));
  68. return s;
  69. }
  70.  
  71. signed main()
  72. {
  73. ios_base::sync_with_stdio(0);
  74. cin.tie(0);
  75. cout.tie(0);
  76. string e = "7182818284590452353602875000";
  77. int n;
  78. cin >> n;
  79. if (n == 0) cout << 3;
  80. else {
  81. cout << "2.";
  82. string q;
  83. for (int i = 0; i < n + 1; i++) {
  84. q += e[i];
  85. }
  86. q = t(q);
  87. for (int i = 0; i < n; i++) cout << q[i];
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement