Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <cmath>
- using namespace std;
- void x(int *a)
- {
- int i1=0;
- int f1=*a;
- int s1=0;
- int c1=0;
- int a3=*a;
- int f=*a;
- while (*a!=0)
- {
- ++i1;
- c1=*a%10;
- *a/=10;
- }
- do
- {
- int k=pow(10,i1);
- s1+=f1/k;
- f1%=k;
- --i1;
- } while (i1!=0);
- int a2=s1+f%10;
- int a1=a2/10+a2%10;
- if (a1>10) {
- a1/=2;
- a2-=a1;
- }
- else {
- if (a1==a2 && a1) {
- *a=a3+a1;
- }else {
- *a=a3+a2+a1;
- }
- }
- }
- int main() {
- // long long int s,a2,f,b,c;
- // bool x=false;
- // int c1=0;
- // int i1=0;
- // int s1=0;
- // cin>>b;
- // for ( int d=1;d<=9;++d) {
- // s=0;
- // i1=0;
- // for (int i=1;i<=9;++i) {
- // for (int j=0;j<=9;++j) {
- // if (i+j==d)
- // {
- // a2=i*10+j;
- // s=d+a2;
- // f=b-s;
- // long long int f1=f;
- // long long int b1=f;
- // while (f!=0) {
- // ++i1;
- // c1=f%10;
- // f/=10;
- // }
- // do {
- // int k=pow(10,i1);
- // s1+=f1/k;
- // f1%=k;
- // --i1;
- // } while (i1!=0);
- // if (s1+b1%10==a2)
- // {
- // cout<<b1;
- // x=true;
- // }
- // else if (d==9 && s+b1%10!=a2 && a2==90)
- // {
- // cout<<-1;
- // x=true;
- // }
- // }
- // if (x==true) {
- // break;
- // }
- // }
- // if (x==true) {
- // break;
- // }
- // }
- // if (x==true) {
- // break;
- // }
- // }
- int b, i, g;
- cin>>b;
- if (b<10){
- cout<<b;
- }
- else if (b==10)
- {
- cout<<-1;
- }
- else
- {
- for (i=b;i>b/1.5;--i)
- {
- g=i;
- x(&g);
- if (g==b)
- break;
- else if (i == b - 200)
- break;
- }
- }
- if (i == floor(b / 1.5))
- {
- cout << -1;
- }
- else if (i == b - 200)
- {
- cout << -1;
- }
- else
- {
- cout << i;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement