Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<climits>
- using namespace std;
- ifstream fin("pointland.in");
- ofstream fout("pointland.out");
- int j[1005];
- int main()
- {
- int x10=0, y10=0, nrc=0, nrcif=0, cifra, t, v, c=0, i;
- long long xpl, aux2, aux3, aux, aux1, n1, n2, rez, r;
- char op;
- fin>>v;
- if(v==1)
- {
- fin>>xpl;
- aux=xpl;
- do
- {
- nrcif++;
- aux=aux/10;
- }
- while(aux!=0);
- aux1=xpl;
- for(i=1; i<=nrcif; i++)
- {
- cifra=aux1%10;
- t=i*(i+1)/2;
- x10=x10+cifra*t;
- aux1=aux1/10;
- }
- fout<<x10;
- }
- if(v==2)
- {
- fin>>n1>>op>>n2;
- aux=n1;
- do
- {
- nrcif++;
- aux=aux/10;
- }while(aux!=0);
- aux1=n1;
- for(i=1; i<=nrcif; i++)
- {
- cifra=aux1%10;
- t=i*(i+1)/2;
- x10=x10+cifra*t;
- aux1=aux1/10;
- }
- aux2=n2;
- do
- {
- nrc++;
- aux2=aux2/10;
- }while(aux2!=0);
- aux3=n2;
- for(i=1; i<=nrc; i++)
- {
- cifra=aux3%10;
- t=i*(i+1)/2;
- y10=y10+cifra*t;
- aux3=aux3/10;
- }
- if(op=='+')
- {
- rez=x10+y10;
- }
- if(op=='-')
- {
- rez=x10-y10;
- }
- if(op=='*')
- {
- rez=x10*y10;
- }
- if(op=='/')
- {
- rez=x10/y10;
- }
- int l=0; fout<<rez<<endl;
- for(i=1; i<=INT_MAX; i++)
- {
- if(aux+i+1<=rez)
- {
- l++;
- j[i]=i*(i+1)/2;
- aux=j[i];
- }
- else
- {
- break;
- }
- }
- /* for(i=l; i>=1; i--)
- {
- vec=v[i];
- while(rez-vec>0)
- {
- c++;
- }
- fout<<c;
- }*/
- }
- if(v==3)
- {
- fin>>xpl;
- aux=xpl;
- do
- {
- nrcif++;
- aux=aux/10;
- }while(aux);
- t=nrcif*(nrcif+1)/2;
- fout<<t;
- }
- fin.close();
- fout.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement