fork download
  1. #include<iostream>
  2. # include <cmath>
  3. # include <algorithm>
  4. # include <cstdio>
  5. # include <cstring>
  6. # include <string>
  7. # include <cstdlib>
  8. # include <vector>
  9. # include <bitset>
  10. # include <map>
  11. # include <queue>
  12. # include <stack>
  13. # include <set>
  14. # include <list>
  15. # include <deque>
  16. # include <functional>
  17. using namespace std;
  18.  
  19. #define DEBUG
  20.  
  21.  
  22. #define DEB(x) cout<<#x<<"="<<x<<" "
  23. #define DEBN(x) cout<<#x<<"="<<x<<"\n"
  24.  
  25.  
  26. #ifdef DEBUG
  27. #define D(x) DEBN(x)
  28. #define DN(x) DEBN(x)
  29. #define DA(a,n) cout<<#a<<"=["; printarray(a,n); cout<<"]\n"
  30. #define DAR(a,n,s) cout<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cout<<"]\n"
  31. #else
  32. #define D(x)
  33. #define DN(x)
  34. #define DA(a,n)
  35. #define DAR(a,n,s)
  36. #endif
  37.  
  38. #ifdef DEBUG
  39. #define DPR(fmt, ...) \
  40. do { printf(fmt, ## __VA_ARGS__); } while (0)
  41. #else
  42. #define DPR(fmt, ...) \
  43. do { } while (0)
  44. #endif
  45.  
  46. #define PR(fmt, ...) \
  47. do { printf(fmt, ## __VA_ARGS__); } while (0)
  48.  
  49.  
  50. // Useful constants
  51.  
  52. #define INF (int)1e9
  53. #define EPS (double)1e-9
  54. # define mod 1000000007
  55. # define PI 3.14159265f
  56.  
  57. #define pii pair<int,int>
  58. #define pll pair<long long,long long>
  59. #define mp make_pair
  60. #define F first
  61. #define S second
  62. #define ll long long
  63.  
  64. #define tri pair< int,pii >
  65. #define trl pair< long long,pll >
  66. #define Ft first
  67. #define St second.first
  68. #define Tt second.second
  69. #define mkt(a,b,c) mp(a,mp(b,c))
  70.  
  71.  
  72. #define Max(a,b) (a>b?a:b)
  73. #define Min(a,b) (a<b?a:b)
  74. #define FI(n) for(i=0;i<n;i++)
  75. #define FI1(n) for(i=1;i<n;i++)
  76. #define FJ(n) for(j=0;j<n;j++)
  77. #define FJ1(n) for(j=1;j<n;j++)
  78. #define FJI for(j=0;j<i;j++)
  79. #define FJI1 for(j=1;j<i;j++)
  80. #define FJIE for(j=0;j<=i;j++)
  81. #define FJIE1 for(j=1;j<=i;j++)
  82. #define For(i,a,b) for(i=a;i<b;i++)
  83.  
  84. // Input macros
  85. #define s(n) scanf("%d",&n)
  86. #define sc(n) scanf("%c",&n)
  87. #define sl(n) scanf("%I64d",&n)
  88. #define sf(n) scanf("%lf",&n)
  89. #define ss(n) scanf("%s",n)
  90.  
  91. //Output macros
  92. #define pr(n) printf("%d ",n)
  93. #define prn(n) printf("%d\n",n)
  94. #define prc(n) printf("%c",n)
  95. #define prcn(n) printf("%c\n",n)
  96. #define prl(n) printf("%I64d ",n)
  97. #define prln(n) printf("%I64d\n",n)
  98. #define prf(n) printf("%lf ",n)
  99. #define prfn(n) printf("%lf\n",n)
  100. #define prs(n) printf("%s ",n)
  101. #define prsn(n) printf("%s\n",n)
  102.  
  103.  
  104.  
  105. //STL containers
  106. #define foreach(v, c) for( typeof( (c).begin()) v = (c).begin(); v != (c).end(); ++v)
  107. #define all(a) a.begin(), a.end()
  108. #define in(a,b) ( (b).find(a) != (b).end())
  109. #define in2(a,b) ( find(all(b),a) != (b).end())
  110. #define pb push_back
  111. #define sz(a) ((int)(a.size()))
  112. #define vi vector<int>
  113. #define vl vector<long long>
  114. #define svi(vec,n) FI(n) s(vec[i])
  115. #define svl(vec,n) FI(n) sl(vec[i])
  116. #define it ::iterator
  117.  
  118. //fill char arrays
  119. #define fill(a,v) memset(a, v, sizeof (a))
  120.  
  121. #define checkbit(n,b) ( (n >> b) & 1)
  122. #define INDEX(arr,ind) (lower_bound(all(arr),ind)-arr.begin())
  123. #define sor(a) sort(all(a))
  124. #define rsor(a) sort(all(a)); reverse(all(a));
  125. #define exchange(t,a,b) typeof(a) t =a; a=b; b=t
  126. //STL output ********************************
  127. template <typename T1, typename T2>
  128. inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
  129. {
  130. return os << "(" << p.first << ", " << p.second << ")";
  131. }
  132.  
  133. template<typename T>
  134. inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
  135. {
  136. bool first = true;
  137. os << "[";
  138. for(unsigned int i = 0; i < v.size(); i++)
  139. {
  140. if(!first)
  141. os << ", ";
  142. os << v[i];
  143. first = false;
  144. }
  145. return os << "]";
  146. }
  147.  
  148.  
  149. template<typename T>
  150. inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
  151. {
  152. bool first = true;
  153. os << "[";
  154. for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
  155. {
  156. if(!first)
  157. os << ", ";
  158. os << *ii;
  159. first = false;
  160. }
  161. return os << "]";
  162. }
  163.  
  164.  
  165. template<typename T1, typename T2>
  166. inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
  167. {
  168. bool first = true;
  169. os << "[";
  170. for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
  171. {
  172. if(!first)
  173. os << ", ";
  174. os << *ii ;
  175. first = false;
  176. }
  177. return os << "]";
  178. }
  179. //*****************************************
  180. //printing array
  181. template<typename T,typename T2>
  182. void printarray(T a[],T2 sz,T2 beg=0)
  183. {
  184. for(T2 i=beg;i<sz;i++) cout<<a[i]<<" ";
  185. }
  186. //*********************************8
  187. bool check(pii a,pii b)
  188. {
  189. int ds=pow(a.F-b.F,2)+pow(a.S-b.S,2);
  190. D(a);D(b);
  191. D((pow(sqrt(ds),2)==ds));
  192. return pow(sqrt(ds),2)==ds;
  193. }
  194. int main()
  195. {
  196. //freopen(".txt","r",stdin);
  197. //freopen(".txt","w",stdout);
  198. int i,j,k;
  199. int n,m;
  200. s(n);s(m);
  201. vector<pii > pnts;
  202. FI(n+1) FJ(m+1)
  203. {
  204. if(i==0 && j==0) continue;
  205. For(k,0,sz(pnts))
  206. {
  207. if(check(pnts[k],mp(i,j))) break;
  208. }
  209. if(k==sz(pnts)) pnts.pb(mp(i,j));
  210. }
  211. prn(sz(pnts));
  212. FI(sz(pnts))
  213. {
  214. pr(pnts[i].F);
  215. prn(pnts[i].S);
  216. }
  217.  
  218. return 0;
  219. nosol:
  220. prn(-1);
  221. return 0;
  222. }
Success #stdin #stdout 0.01s 2864KB
stdin
2 2
stdout
a=(0, 1)
b=(0, 2)
(pow(sqrt(ds),2)==ds)=1
a=(0, 1)
b=(1, 0)
(pow(sqrt(ds),2)==ds)=1
a=(0, 1)
b=(1, 1)
(pow(sqrt(ds),2)==ds)=1
a=(0, 1)
b=(1, 2)
(pow(sqrt(ds),2)==ds)=1
a=(1, 0)
b=(1, 2)
(pow(sqrt(ds),2)==ds)=1
a=(0, 1)
b=(2, 0)
(pow(sqrt(ds),2)==ds)=1
a=(0, 1)
b=(2, 1)
(pow(sqrt(ds),2)==ds)=1
a=(0, 1)
b=(2, 2)
(pow(sqrt(ds),2)==ds)=1
2
0 1
1 0