ACM 训练日志记录 · 思考 · 成长 提交 / 修改记录
王梓豪 / 题目列表训练档案
导出

Integer Triple(CCPC网络赛)

来源:其他 ★ 1400

本题活力0.34按难度、完成结果与训练证据估算

算法如山行则将至

题目描述

Integer Triple
Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 512 megabytes
Given an integer n, find three integers a, b, c satisfying
• |a|, |b|, |c| ≤ 1018;
• n = ab(a + b) + bc(b + c) + ac(a + c).
If no such triple of integers exists, report that there is no solution.
Input
The input contains one integer n (0 ≤ n ≤ 1018).
Output
If there is no solution, output −1. Otherwise, output three integers a, b, c that satisfy all the requirements.
If there are multiple valid answers, output any one of them.
Examples
standard input standard output
3 -1
6 1 1 1

代码

if(!n%2)
{a=n/2;
b=1;
c=-1;
cout<<a<<' '<<b<<' 'c<<endl;}
else
{cout<<-1<<endl;
}