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() {
- int b=0;
- cin>>b;
- if (b<10)
- {
- cout<<b;
- }
- else if (b<=10)
- {
- cout<<-1;
- }else
- {
- for (int i=b;i>=floor(b/1.5);--i)
- {
- int g=i;
- x(&g);
- if (g==b)
- {
- cout<<i;
- break;
- }
- else if (i == b - 200 || i == floor(b / 1.5) )
- {
- cout<<-1;
- break;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement