Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- using namespace std;
- # define M_PI 3.14159265358979323846
- #define pb push_back
- int transformer(string x){
- if(x=="patrat")
- return 0;
- else if(x=="dreptunghi")
- return 1;
- else if(x=="cerc")
- return 2;
- else if(x=="triunghi")
- return 3;
- return -1;
- }
- class Prisme{
- public:
- string tipP;
- float h,l,L,r,c1,c2;
- const int gem=2,frisca=1;
- Prisme(string Type,float height,float lorr){
- h=height;
- if(Type=="patrat")
- l=lorr;
- else
- r=lorr;
- tipP=Type;
- }
- Prisme(string Type,float height,float l,float L){
- h=height;
- if(Type=="dreptunghi"){
- this->l=l;
- this->L=L;
- }else{
- this->c1=l;
- this->c2=L;
- }
- tipP=Type;
- }
- float getGem(){
- switch(transformer(this->tipP)){
- case 0:
- return gem*(l*l*h);
- case 1:
- return gem*(l*L*h);
- case 2:
- return gem*(M_PI*r*r*h);
- case 3:
- return gem*(c1*c2*h/2);
- default:
- return -1;
- }
- }
- float getFrisca(){
- switch(transformer(this->tipP)){
- case 0:
- return (l*l*2+l*h*4)*frisca;
- case 1:
- return (l*L*2+L*h*2+l*h*2)*frisca;
- case 2:
- return (2*M_PI*(r*2))*((r*2)+h)*frisca;
- case 3:
- return ((c1+c2+sqrt(c1*c1+c2*c2))*h+(c1*c2))*frisca;
- default:
- return -1;
- }
- }
- };
- int sumdiv(int x){
- long sum =1,i=0;
- for(i=2;i*i<x;++i)
- if(x%i==0)
- {
- sum+=i;
- sum+=(x/i);
- }
- sum+=((x%i==0)?i:0);
- return (sum==x);
- }
- int main()
- {
- long a,b;
- cin>>a>>b;
- cout<<a+b;
- for(int i=a;i<=b;i++)
- if(sumdiv(i))
- cout<<i<<' ';
- vector<Prisme> listaP;
- string X;
- while(cin>>X){
- if(X=="ADD"){
- float h,l,L,r;
- string Type;
- cin>>Type;
- if(transformer(Type)==0){
- cin>>h>>l;
- listaP.pb(new Prisme(Type,h,l));
- }
- else if(transformer(Type)==1){
- cin>>h>>l>>L;
- listaP.pb(new Prisme(Type,h,l,L));
- }
- else if(transformer(Type)==2){
- cin>>h>>l;
- listaP.pb(new Prisme(Type,h,l));
- }
- else if(transformer(Type)==3){
- cin>>h>>l>>L;
- listaP.pb(new Prisme(Type,h,l,L));
- }
- cout<<listaP.back().getGem()<<' '<<listaP.back().getFrisca()<<'\n';
- }
- else{
- int removal;
- cin>>removal;
- listaP.erase(listaP.begin()+removal-1);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement