Bob is playing a game named "Walk on Matrix".
In this game, player is given an n×mn×m matrix A=(ai,j)A=(ai,j), i.e. the element in the ii-th row in the jj-th column is ai,jai,j. Initially, player is located at position (1,1)(1,1) with score a1,1a1,1.
To reach the goal, position (n,m)(n,m), player can move right or down, i.e. move from (x,y)(x,y) to (x,y+1)(x,y+1) or (x+1,y)(x+1,y), as long as player is still on the matrix.
However, each move changes player's score to the bitwise AND of the current score and the value at the position he moves to.
Bob can't wait to find out the maximum score he can get using the tool he recently learnt — dynamic programming. Here is his algorithm for this problem.
![](https://espresso.codeforces.com/52569ca543bc97ed169bbc3ee5e3975b65a6b3b6.png)
However, he suddenly realize that the algorithm above fails to output the maximum score for some matrix AA. Thus, for any given non-negative integer kk, he wants to find out an n×mn×m matrix A=(ai,j)A=(ai,j) such that
- 1≤n,m≤5001≤n,m≤500 (as Bob hates large matrix);
- 0≤ai,j≤3⋅1050≤ai,j≤3⋅105 for all 1≤i≤n,1≤j≤m1≤i≤n,1≤j≤m (as Bob hates large numbers);
- the difference between the maximum score he can get and the output of his algorithm is exactly kk.
It can be shown that for any given integer kk such that 0≤k≤1050≤k≤105, there exists a matrix satisfying the above constraints.
Please help him with it!
The only line of the input contains one single integer kk (0≤k≤1050≤k≤105).
Output two integers nn, mm (1≤n,m≤5001≤n,m≤500) in the first line, representing the size of the matrix.
Then output nn lines with mm integers in each line, ai,jai,j in the (i+1)(i+1)-th row, jj-th column.
0
1 1 300000
1
3 4 7 3 3 1 4 8 3 6 7 7 7 3
In the first example, the maximum score Bob can achieve is 300000300000, while the output of his algorithm is 300000300000.
In the second example, the maximum score Bob can achieve is 7&3&3&3&7&3=37&3&3&3&7&3=3, while the output of his algorithm is 22.
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <set> #include <queue> #include <map> #include <sstream> #include <cstdio> #include <cstring> #include <numeric> #include <cmath> #include <iomanip> #include <deque> #include <bitset> //#include <unordered_set> //#include <unordered_map> //#include <bits/stdc++.h> //#include <xfunctional> #define ll long long #define PII pair<int, int> using namespace std; int dir[5][2] = { { 0,1 } ,{ 0,-1 },{ 1,0 },{ -1,0 } ,{ 0,0 } }; const long long INF = 0x7f7f7f7f7f7f7f7f; const int inf = 0x3f3f3f3f; const double pi = 3.14159265358979; const int mod = 1e9 + 7; const int maxn = 2005; //if(x<0 || x>=r || y<0 || y>=c) //1000000000000000000 inline ll read() { ll x = 0; bool f = true; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = false; c = getchar(); } while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar(); return f ? x : -x; } int k; int Add; int a[5][5]; map<int, bool>vis; int main() { k=read(); if (k == 0) { printf("1 1 "); printf("23333"); } else { printf("2 3 "); int Num = 1; for (int cnt = 0; cnt <= 17; cnt++) { vis[Num] = true; if (Num >= k) break; Num *= 2; } if (vis[k] == true) Num *= 2; a[1][1] = Num * 2 - 1; a[1][2] = k; a[1][3] = 0; a[2][1] = Num; a[2][2] = Num * 2 - 1; a[2][3] = k; for (int i = 1; i <= 2; i++) { for (int j = 1; j <= 3; j++) { printf("%d ", a[i][j]); } puts(""); } } return 0; }