P12334
Nightsky_Stars · · 题解
思路:
设
因为
因为
所以我们可以从
CODE:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
#ifdef ONLINE_JUDGE
ios::sync_with_stdio(0);
#endif
cin.tie(0);
cout.tie(0);
ll y;
cin>>y;
for(ll i=sqrtl(y-1)+1;i<=sqrt(y-1)+1+10;i++){//注意是向上取整
if(i*i%9==y%9){
cout<<i<<"\n";
#ifndef ONLINE_JUDGE
system("pause");
#endif
return 0;
}
}
cout<<"-1\n";
#ifndef ONLINE_JUDGE
system("pause");
#endif
return 0;
}