Kattis Problem Solution to R2 in C++ Get link Facebook X Pinterest Email Other Apps April 27, 2020 #include<bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int r1,s; cin>>r1>>s; cout<<((2*s)-r1); return 0; } Get link Facebook X Pinterest Email Other Apps Comments
Basketball One-on-One : Kattis Solution in C++ April 29, 2020 #include<bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]){ string n; cin >> n; int len = n.length(); int scoreA = 0,scoreB = 0; for (int i = 0; i < len; i+=2) { if(n[i] == 'A'){ int score = n[i+1] - '0'; scoreA += score; }else if(n[i] == 'B'){ int score = n[i+1] - '0'; scoreB += score; } } (scoreA > scoreB) ? cout << 'A' : cout << 'B'; return 0; } question Link : https://open.kattis.com/problems/basketballoneonone Read more
Kattis Solution to Reverse Binary in C++ April 27, 2020 #include<bits/stdc++.h> using namespace std; // using namespace std::chrono; int main(int argc, char const *argv[]) { int n,i=0,t; cin >> n; vector<int>v; // auto start = high_resolution_clock::now(); while(true){ t = n % 2; v.push_back(t); n = n / 2; if(n == 0 ) break; i++; } // auto stop = high_resolution_clock::now(); // auto duration = duration_cast<microseconds>(stop-start); // cout << duration.count()<<endl; reverse(v.begin(),v.end()); int index = 0,sum = 0; for(auto b : v){ if(b == 1){ sum+=pow(2,index); ... Read more
Kattis Problem Solution To Quality-Adjusted Life-Quality April 27, 2020 #include <iostream> using namespace std ; int main ( int argc , char const * argv [ ]) { int n ; float q , y , qaly = 0.0 ; cin >> n ; while ( n -- ) { cin >> q >> y ; qaly += ( q * y ) ; } cout << qaly ; return 0 ; } Read more
Comments
Post a Comment