AlgorithmOJ
Problem
Local Problems
All Problems
Problem Category
Status
Contest
Standard Contests
Replay Contests
Virtual Contests
Ranklist
More...
News
About
F.A.Q
Recent Contests
Coming Soon...
Login
Register
2026-08-16 10:42:31
不定方程组
Time Limit:
1000ms
Memory Limit:
Unknown KB
This problem will be judged on
PKU
. Original ID:
1831
64-bit integer IO format:
%lld
Java class name:
Main
Special Judge
Prev
Submit
Status
Statistics
Next
Font Size:
Description
考虑不定方程组
a1 + a2 + a3 + … + an = s
1 / a1 + 1 / a2 + 1 / a3 + … + 1 / an = 1
其中n, a1, a2 …均为参数,s已知。
给出s求出不定方程组的一组正整数解。
Input
第一行是一个正整数m,表示测试数据的组数,每组测试数据只有一行,一个正整数s( 1<=s<65536)。
Output
对每组测试数据输出一行,如果方程组无解,则输出-1,否则先输出正整数n,然后输出n个数a1 a2 … an,数据之间用空格隔开。
Sample Input
3 1 2 10
Sample Output
1 1 -1 3 2 4 4
Source
qinlu@POJ
Language:
C++
C++11
C++14
C
Java
Pascal
Python2
Python3
C#
Fortran
Perl
Ruby
Ada
SML
Visual C++
Visual C
CLang
CLang++
Theme:
Monokai
Solarized Light
Material
Share Code?
Yes
No
×
Login
Username:
Password:
Cookie:
Never
One Day
One Week
One Month
One Year
×
Register
Username:
Password:
Repeat Password:
Nickname:
School:
Email:
×
News Title
by