2072E. Do You Love Your Hero and His Two-Hit Multi-Target Attacks? · znzryb
## 思路讲解
设c为斜边,a,b为直角边
$$
\begin{cases}
a^2 + b^2 = c^2 \\
a + b = c
\end{cases} \\ a^2+b^2=(a+b)^2 \\ 2ab=0
$$
所以说a,b中必然有一为0。换言之,满足题设条件的充要条件是两个点在同一水平线或同一垂直线上。
## AC代码
直接AC,没什么好说的
[https://codeforces.com/problemset/submission/2072/309435277](https://codeforces.com/problemset/submission/2072/309435277)
```cpp
// Problem: E. Do You Love Your Hero and His Two-Hit Multi-Target Attacks?
// Contest: Codeforces - Codeforces Round 1006 (Div. 3)
// URL: https://codeforces.com/problemset/problem/2072/E
// Memory Limit: 256 MB
// Time Limit: 3000 ms
// by znzryb
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
#define FOR(i, a, b) for (long long i = (a); i <= (b); ++i)
#define ROF(i, a, b) for (long long i = (a); i >= (b); --i)
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define fi first
#define se second
#define pb push_back
#define SZ(a) ((int) a.size())
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef array<ll,3> arr;
typedef double DB;
typedef pair<DB,DB> pdd;
constexpr ll MAXN=static_cast<ll>(5e3)+10,INF=static_cast<ll>(5e18)+3;
ll K,T;
inline void solve(){
cin>>K;
vector<pll> ans;
ll upj=1;
for(int i=1;i<=500;++i){
if(K==0) break;
ll idx=0;
for(int j=upj;j<=500+upj;++j){
if(K-idx<0) {
upj=j;
break;
}
K-=idx;
ans.pb({i,j});
++idx;
}
}
// #ifdef LOCAL
// cerr<< << ans.size() << '\n';
// #endif
cout<<ans.size()<<"\n";
for(int i=0;i<ans.size();++i){
cout<<ans[i].fi<<" "<<ans[i].se<<"\n";
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>T;
while(T--){
solve();
}
return 0;
}
/*
AC
https://codeforces.com/problemset/submission/2072/309435277
*/
```
## 心路历程(WA,TLE,MLE……)