Skip to content

Instantly share code, notes, and snippets.

@oisincar
Last active February 13, 2019 02:20
Show Gist options
  • Save oisincar/fed9fcb1770e04de86207f5fc3d4f905 to your computer and use it in GitHub Desktop.
Save oisincar/fed9fcb1770e04de86207f5fc3d4f905 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int main(){
int o,O;
while(cin>>o>>O,O++||o)
cout<<(2>O&&o%2?-1:(o+O/2+O+3-O%2*3)/2+(o+O/2)%2*3)<<"\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment