Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <stack>
- #include <set>
- #include <list>
- #include <map>
- #include <deque>
- #include <cmath>
- #include <vector>
- #include <utility>
- #include <cstdio>
- #include <cstdlib>
- #include <algorithm>
- #include <functional>
- #include <sstream>
- // short keywords
- #define ipow(a,b) (int)pow(a,b)
- #define pb push_back
- #define mp make_pair
- #define mod 1000000007
- // for loops
- #define rep(i,n) for(int i=0;i<n;i++)
- #define reps(i,a,b) for(int i=a;i<=b;i++)
- #define rev(i,a,b) for(int i=a;i>=b;i--)
- using namespace std;
- // short keywords2
- typedef long long ll;
- typedef long double ld;
- typedef set<int>::iterator sit;
- typedef map<int,int>::iterator mit;
- class Point
- {
- private:
- int a;
- int b;
- public :
- Point(int a, int b)
- {
- this->a=a;
- this->b=b;
- }
- void setfirst(int a)
- {
- this->a=a;
- }
- void setsecond(int b)
- {
- this->b=b;
- }
- int getfirst()const
- {
- return a;
- }
- int getsecond()const
- {
- return b;
- }
- };
- struct compare
- {
- bool operator()(const Point& a,const Point& b)
- {
- if(a.getfirst()>b.getfirst())
- {
- return true;
- }
- else
- {
- if(a.getsecond()>b.getsecond())
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- };
- class Task
- {
- public:
- const int mod2=1000000;
- void solve(istream& in,ostream& out)
- {
- int t;
- in>>t;
- map<Point,int,compare>store;
- for(int i=0;i<11111;i++)
- {
- if(i%2==0)
- {
- Point check(i,i);
- store.insert(mp(check,2*i));
- }
- else
- {
- Point check(i,i);
- store.insert(mp(check,2*i-1));
- }
- }
- for(int i=2;i<11111;i++)
- {
- Point check(i,i-2);
- if(i%2==0)
- {
- store.insert(mp(check,2*i-2));
- }
- else
- {
- store.insert(mp(check,2*i-3));
- }
- }
- for(auto h=store.begin();h!=store.end();h++)
- {
- out<<((*h).first).getfirst()<<" "<<((*h).first).getsecond()<<endl;
- }
- rep(j,t)
- {
- int a,b;
- in>>a>>b;
- Point point(a,b);
- if(store.find(point)==store.end())
- {
- out<<"No Number"<<endl;
- }
- else
- {
- out<<(*store.find(point)).second<<endl;
- }
- }
- }
- int gcd(int a,int b)
- {
- if(a==0)
- {
- return b;
- }
- else
- {
- return gcd(b%a,a);
- }
- }
- };
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- Task solver;
- std::istream& in(std::cin);
- std::ostream& out(std::cout);
- solver.solve(in,out);
- out.flush();
- return 0;
- }
Add Comment
Please, Sign In to add comment