Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include<iostream>
- //using namespace std;
- //int main(){
- // int n,position,numbertoInsert,buf;
- // cin>>n;
- // int arr[n];
- // for(int i=0; i<n; i++){
- // cin>>arr[i];
- // }
- // cin>>numbertoInsert>>position;
- // if(position>=n)
- // {
- // position=n-1;
- // }
- // buf=arr[n-1];
- // for(int i=n-1; i>position; i--)
- // {
- // arr[i]=arr[i-1];
- // }
- // arr[position]=numbertoInsert;
- // for(int i=0; i<n; i++)
- // {
- // cout<<arr[i]<<" ";
- // }
- // return 0;
- //}
- #include<iostream>
- using namespace std;
- int main() {
- int a1,a2,a3,b;
- bool x=false;
- cin>>b;
- for (int d=0;d<=9;++d) {
- for (int i=1;i<=9;++i) {
- for (int j=0;j<=9;++j) {
- if (i+j==d)
- {
- a2=i*10+j;
- if (((b-(d+a2))/10+(b-(d+a2))%10)==a2)
- {
- cout<<b-(d+a2);
- x=true;
- }
- else if (d==9 && ((b-(d+a2))/10+(b-(d+a2))%10)!=a2)
- {
- cout<<-1;
- x=true;
- }
- }
- if (x==true) {
- break;
- }
- }
- if (x==true) {
- break;
- }
- }
- if (x==true) {
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement