Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ozd
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n, k;
- cin>>n;
- cin>>k;
- int neededRed = n*2;
- int neededGreen = n*5;
- int neededBlue = n*8;
- int booksToBuy = 0;
- booksToBuy += ceil(double(neededRed)/k);
- booksToBuy += ceil(double(neededGreen)/k);
- booksToBuy += ceil(double(neededBlue)/k);
- cout << booksToBuy << endl;
- return 0;
- }
- //////////////////////////// ppk
- #include <bits/stdc++.h>
- using namespace std;
- long long getCSquared(int a , int b){
- return pow(a, 2) + pow(b, 2);
- }
- int main()
- {
- int n;
- cin>>n;
- int x[100000];
- int y[100000];
- for(int i = 0; i < n; i++){
- cin>>x[i];
- cin>>y[i];
- }
- int maxX = 0;
- int maxY = 0;
- for(int i = 0; i < n; i++){
- if(getCSquared(x[i], y[i]) > getCSquared(maxX, maxY)){
- maxX = x[i];
- maxY = y[i];
- }
- }
- while(maxY > 0){
- maxX++;
- maxY--;
- }
- cout << maxX << endl;
- return 0;
- }
- ////////////////////// raz
- #include <bits/stdc++.h>
- using namespace std;
- string reverseString(string word){
- string output = "";
- for(int i = word.length()-1; i >= 0; i--){
- output = output + string(1, word[i]);
- }
- return output;
- }
- string scramble(string word){
- string output = "";
- string wordReverse = reverseString(word);
- for(int i = 0; i < floor(word.length()/2.0); i++){
- output = output + string(1, word[i]) + string(1, wordReverse[i]);
- }
- if(word.length() % 2 == 1){
- output = output + word[ceil(word.length()/2.0 - 1)];
- }
- return output;
- }
- int main()
- {
- int n;
- cin>>n;
- string words[1000];
- for(int i = 0; i < n; i++){
- cin>>words[i];
- }
- for(int i = 0; i < n; i++){
- cout << scramble(words[i]) << endl;
- }
- return 0;
- }
- ////////////////// wla
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- vector<int> a;
- for(int i = 0; i < n; i++){
- int val;
- cin>>val;
- a.push_back(val);
- }
- sort(a.begin(), a.end());
- int stolen = 0;
- int prevLeftIndex = 0;
- for(int i = 1; i < n; i++){
- if(a[prevLeftIndex] == a[i] - 1)
- prevLeftIndex++;
- else {
- stolen += a[i] - a[prevLeftIndex] - 1;
- prevLeftIndex++;
- }
- }
- cout << stolen << endl;
- return 0;
- }
- ////////////// wyd
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- int r;
- cin>>r;
- int minCoins = r/n + (r%n != 0);
- cout << minCoins << endl;
- return 0;
- }
- /////////////////////// bin
- #include <bits/stdc++.h>
- using namespace std;
- int howManyZeros(string s){
- int out = 0;
- for(int i = 0; i < s.length(); i++){
- if(s[i] == '0') out++;
- }
- return out;
- }
- string modify(string val){
- string output = "";
- if(val == "0")
- output = "0";
- else {
- output = "1";
- for(int i = 0; i < howManyZeros(val); i++) output = output + "0";
- }
- return output;
- }
- int main()
- {
- int n;
- cin>>n;
- for(int i = 0; i < n; i++){
- string b;
- cin>>b;
- cout << modify(b) << endl;
- }
- return 0;
- }
- //////////////////// fig
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- vector<int> shapes;
- for(int i = 0; i < n; i++){
- int s;
- cin>>s;
- shapes.push_back(s);
- }
- bool canFind = false;
- for(int i = 1; i < n-1; i++){
- if(shapes[i] == 0){
- if((shapes[i-1] == 1 && shapes[i+1] == 2) || (shapes[i-1] == 2 && shapes[i+1] == 1)){
- canFind = true;
- break;
- }
- }
- if(shapes[i] == 1){
- if((shapes[i-1] == 0 && shapes[i+1] == 2) || (shapes[i-1] == 2 && shapes[i+1] == 0)){
- canFind = true;
- break;
- }
- }
- if(shapes[i] == 2){
- if((shapes[i-1] == 0 && shapes[i+1] == 1) || (shapes[i-1] == 1 && shapes[i+1] == 0)){
- canFind = true;
- break;
- }
- }
- }
- if(canFind)
- cout << "TAK" << endl;
- else
- cout << "NIE" << endl;
- return 0;
- }
- //////////////////// pla
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- vector<int> a;
- for(int i = 0; i < n; i++){
- int v;
- cin>>v;
- a.push_back(v);
- }
- while(true){
- if(a.size() > 0){
- if(a[0] == 0) a.erase(a.begin());
- else break;
- } else break;
- }
- if(a.size() > 0){
- bool zeros = false;
- int zerosStartIndex;
- for(int i = 0; i < a.size(); i++){
- if(!zeros && a[i] == 0){
- zeros = true;
- zerosStartIndex = i;
- }
- if(zeros && a[i] != 0){
- if(i - zerosStartIndex >= 2){
- a.erase(a.begin()+zerosStartIndex, a.begin()+i);
- i = zerosStartIndex;
- zeros = false;
- } else {
- zeros = false;
- }
- }
- }
- }
- while(true){
- if(a.size() > 0){
- if(a[a.size()-1] == 0) a.erase(a.end()-1);
- else break;
- } else break;
- }
- cout << a.size() << endl;
- return 0;
- }
- ///////////////// dzi
- #include <bits/stdc++.h>
- #include <chrono>
- using namespace std;
- int powersOf2[30] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912};
- bool isPowerOf2(int n){
- for(int i = 0; i < 30; i++){
- if(n == powersOf2[i]) return true;
- }
- return false;
- }
- long long strangeSum(long long n){
- long long sum = (n+1) * n/2;
- for(int i = 0; i < 30; i++){
- if(n >= powersOf2[i]) sum -= 2*powersOf2[i];
- }
- return sum;
- }
- int main()
- {
- int z;
- cin>>z;
- for(int i = 0; i < z; i++){
- int n;
- cin>>n;
- cout<<strangeSum(n)<<endl;
- }
- return 0;
- }
- /////////////// sch
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- int a[10000];
- for(int i = 0; i < n; i++){
- cin>>a[i];
- }
- queue<int> stairs;
- int stairCounter = 1;
- for(int i = 1; i <= n; i++){
- if(i!=n){
- if(a[i] <= a[i-1]){
- stairs.push(stairCounter);
- stairCounter = 1;
- } else stairCounter++;
- } else stairs.push(stairCounter);
- }
- cout<<stairs.size()<<endl;
- while(!stairs.empty()){
- cout<<stairs.front()<<" ";
- stairs.pop();
- }
- return 0;
- }
- ////////////////////// tpa
- #include <bits/stdc++.h>
- using namespace std;
- bool palindromePossible(int arr[], int n){
- for(int i = 0; i <= n/2; i++){
- if((arr[i]==1 && arr[n-1-i]==2) || (arr[i]==2 && arr[n-1-i]==1))
- return false;
- }
- return true;
- }
- int main()
- {
- int n;
- cin>>n;
- int a, b;
- cin>>a;
- cin>>b;
- int dancers[1000];
- for(int i = 0; i < n; i++){
- cin>>dancers[i];
- }
- if(palindromePossible(dancers, n)){
- int cost = 0;
- for(int i = 0; i < floor(n/2.0); i++){
- if(dancers[i]==1 && dancers[n-1-i]==0)
- cost += a;
- else if(dancers[i]==0 && dancers[n-1-i]==1)
- cost += a;
- else if(dancers[i]==2 && dancers[n-1-i]==0)
- cost += b;
- else if(dancers[i]==0 && dancers[n-1-i]==2)
- cost += b;
- else if(dancers[i]==0 && dancers[n-1-i]==0)
- cost += min(a, b);
- }
- if(n%2 == 1){
- if(dancers[(int) floor(n/2.0)] == 0) cost += min(a, b);
- }
- cout<<cost<<endl;
- } else cout<<"NIE"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement