标签:continue 多少 tin 个数 数加 开始 while 计算 play
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<bitset>
using namespace std;
typedef long long ll;
ll read() {
ll x=0,f=1;char c=getchar();
while(c<'0'||c>'9') {
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9') {
x=x*10+c-'0';
c=getchar();
}
return x*f;
}
ll x;
ll x2;
ll sum,sum_;
int check(int x,int y) {
return sum_-x+y==sum;
}
int main() {
int n=read();
for(ll i=1;i<=n;++i) {
x+=i*i;
sum+=i;
}
for(int i=1;i<=n;++i) {
ll k=read();
sum_+=k;
x2+=k*k;
}
ll z=x-x2;
for(ll i=1;i<=n;++i) {
ll zz=i*i;
if(zz+z<=0) continue;
ll kk=sqrt(zz+z);
if(kk*kk==zz+z) {
if(!check(i,kk)) continue;
cout<<i;
return 0;
}
}
return 0;
}
标签:continue 多少 tin 个数 数加 开始 while 计算 play
原文地址:https://www.cnblogs.com/wxyww/p/9746071.html