Skip to content

Instantly share code, notes, and snippets.

@wolfsyntax
Last active October 13, 2017 10:27
Show Gist options
  • Save wolfsyntax/75c78ca59093054eca0f8f852ec7b1cb to your computer and use it in GitHub Desktop.
Save wolfsyntax/75c78ca59093054eca0f8f852ec7b1cb to your computer and use it in GitHub Desktop.
A collection of solutions in programming contest
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
/**
ACM - PNPC
- BMI
**/
int main() {
int w, h, bmi = 0;
cin >> w >> h;
bmi = w / (h*h);
cout << (bmi >= 25 ? "GO ON A DIET\n" : "YOU ARE TOO THIN\n");
return 0;
}
#include <bits/stdc++.h>
/**
Calculate the difference and sum of a single digit number
- a single digit character converted to integer by subtracting 48
**/
using namespace std;
int main(){
string equation; cin >> equation;
int ans = 0;
if(equation[1] == '+'){
ans = (equation[0]-48) + (equation[2]-48);
} else {
ans = (equation[0]-48) - (equation[2]-48);
}
cout << ans << endl;
return 0;
}
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int t, Hr, Hb, Wb;
cin >> t;
while(t--){
cin >> Hr >> Hb >> Wb;
int dots = Hr;
int height = Hr + Hb + 1, width = 4+1+Wb;
int roof_len = width-(Hr+Hr);
for(int i = 0; i < height; i++){
string dimen = "";
if(i == 0){
string r1(Hr,'.');
dimen += r1;
string r2(roof_len,'_');
dimen += (r2+r1);
} else {
if(Hr >= 0){
string r1(Hr,'.');
dimen += (r1+"/");
string r2(roof_len,'#');
dimen += (r2+"\\"+r1);
} else if(i < height-3){
string r1(2,'.');
dimen += (r1+"|");
string r2(Wb-1,'.');
dimen += (r2 + "|"+r1);
} else if(i == height-3){
string r1(2,'.');
dimen += (r1+"|");
string r2(Wb-3,'.');
dimen += (r2 + "_.|"+r1);
} else if(i == height-2){
string r1(2,'.');
dimen += (r1+"|");
string r2(Wb-4,'.');
dimen += (r2 + "|.||"+r1);
}else {
string r1(2,'.');
dimen += (r1+"|");
string r2(Wb-4,'_');
dimen += (r2 + "|_||"+r1);
}
roof_len += 2;
}
Hr--;
cout << dimen << endl;
}
cout << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment