Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Toggle navigation
- iRunner 2
- OK Solution 204296
- Result
- Accepted
- Score
- 100 of 100
- Author
- Брест 04
- Problem
- Преобразование последовательности
- Input / output
- input.txt / output.txt
- Contest
- Тренировка 3 на задачах минской районки-2017
- Submitted
- Dec. 16, 2017, 11:08 a.m.
- Judged
- Dec. 16, 2017, 11:08 a.m.
- File
- solution.cpp (1.4 KB)
- Compiler
- C++ GNU C++14 6.2.0 (MinGW) [stack: 64 MB]
- Attempts (2)
- Source code
- Compilation log
- Test results
- Open Download Select all Style: default
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- #include <iostream>
- #include <vector>
- #include <cstdio>
- #include <climits>
- #include <algorithm>
- #include <string>
- #define int long long
- #define For(i,z) for(int i=0;i<z;i++)
- using namespace std;
- const int N = 1e5+2;
- vector<int> ar(N);
- int input() {
- char c = getchar();
- int ans = 0;
- bool neg = false;
- while ((c < '0' || c > '9') && c != '-')
- c = getchar();
- if (c == '-')
- neg = true,
- c = getchar();
- while (c >= '0' && c <= '9')
- ans = ans * 10 + (c - '0'),
- c = getchar();
- if (neg)
- return (-ans);
- else
- return ans;
- }
- int getB(int a) {
- bool ar[32] = {false};
- int ind = 31;
- while (a)
- ar[ind] = a % 2,
- ind--,
- a /= 2;
- int i;
- for (i = ind+1; i < 32; i++)
- if (!ar[i]) {
- ar[i] = true;
- break;
- }
- if (i == 32)
- ar[31] = 0;
- int ans = 0, mn = 1;
- for (i = 31; i > ind; i--)
- ans = ans + ar[i] * mn,
- mn *= 2;
- return ans;
- }
- int32_t main()
- {
- freopen("input.txt","r",stdin);
- freopen("output.txt","w",stdout);
- int n;
- cin >> n;
- ar.resize(n);
- For (i, n)
- ar[i] = getB(input());
- For (i, n) {
- cout << ar[i];
- if (i != n-1)
- cout << " ";
- }
- return 0;
- }
- Insight Runner 2 #b0e0cb6
- © 2001–2017 DMA department of FAMCS BSU
- About Язык / Language Feedback
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement