求NOIP2009年复赛试题解析 只要解题思路即可

来源:百度知道 编辑:UC知道 时间:2024/09/23 18:26:28
只要解题思路就行!谢谢了

提高组的吗??
1:普通模拟
2:如果枚举稳拿50分;如果搜索质因数可以拿满,不过比较麻烦;
3:纯搜索路径最多20;spfa可以拿满;
4:普通搜索可以拿65~75;dancing-link可以拿满分,A*也行,
PS:如果你从右下角到左上角做听说可以拿95分。。。

多项式输出

问题转述:
给出一个一元多项式各项的次数和系数,按照规定的格式要求输出该多项式。
分析:
普及组的水题。多项式大家应该很熟悉,输出的时候注意一下几点即可:
1. 最高次项为正的话开头无加号。
2. 系数为0不输出。
3. 一次项输出x,并非x^1。
4. 非常数项系数为1或-1时直接输出正负号,但是常数项需要输出该数字。
其中除第三项外其它均可在样例中检查出错误,但是若没想到第三点那么就只能得到50分了。

程序:
var i,k,n:longint;
begin
assign(input,'poly.in');reset(input);
assign(output,'poly.out');rewrite(output);
readln(n);
for i:=n downto 0 do
begin
read(k);
if k=0 then continue;
if (k>0) and (i<>n) then write('+');
if i=0 then write(k)
else if (abs(k)<>1) then write(k) else if k=-1 then write('-');
if i<>0 then
if i=1 then write('x')
else write('x^'