B: Break Prime
题目很简单,给定素数让判断是否可以分解成b^3 - a^3的形式。
要用到立方差公式
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define d(x) cout << (x) << endl
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 1e4 + 10;
ll num;
int main(){
while(~scanf("%lld", &num)){
ll x = ll((sqrt(12 * num - 3) - 3) / 6);
if(3*x*x+3*x+1==num){
printf("%lld %lld\n", x, x + 1);
}else{
printf("-1 -1\n");
}
}
return 0;
}