Untitled
unknown
plain_text
8 months ago
1.7 kB
2
Indexable
Never
#include <bits/stdc++.h> using namespace std; #define ll long long const ll MAXN=3001; bool check[MAXN]; ll pos[MAXN],a[MAXN]; // struct kba{ // ll n=0,v=0,t=0; // ll val; // }; int main(){ freopen("TEST.inp","r",stdin); freopen("TEST.out","w",stdout); ll n,t,ghp,ght,ans[4]; memset(ans,0,sizeof(ans)); cin >> n >> t; for(ll i=1;i<=n;i++){ cin >> a[i]; pos[a[i]]=i; check[a[i]]=true; } sort(a+1,a+n+1); for(ll i=1;i<=n-2;i++){ for(ll j=i+1;j<=n-1;j++){ float temp=sqrt(pow(a[i],2)+pow(a[j],2)); if(ceil(temp)==temp){ ll temp2=temp; if(check[temp2]==true){ ans[2]++; } ll temp3=a[i]+a[j]-1; if(temp3<=a[n]){ while(1==1){ if(check[temp3]==true){ ghp=pos[temp3]; break; } temp3--; } ght=pos[temp2]+1; ans[3]+=(ghp-ght+1); } } ght=j+1; ll temp4=temp; if(ceil(temp)==temp){ temp4-=1; } cout << temp4 << endl; if(check[temp4]==false){ while(1==1){ if(check[temp4]==true){ ghp=pos[temp4]; cout << ghp << " "; } temp4--; } } ans[1]+=(ghp-ght+1); } } cout << ans[t]; }
Leave a Comment