<?xml version="1.0" encoding="UTF-8"?> 
<fps version="1.1" url="http://code.google.com/p/freeproblemset/">
	<generator name="HUSTOJ" url="http://code.google.com/p/hustoj/"/>
	<item>
<title><![CDATA[明明的随机数]]></title>
<time_limit><![CDATA[1]]></time_limit>
<memory_limit><![CDATA[128]]></memory_limit>

<description><![CDATA[<p><style type="text/css">p { margin-bottom: 0.21cm; }</style>
<p align="LEFT" style="text-indent: 0.74cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font size="3">明明想在学校中请一些同学一起做一项问卷调查，为了实验的客观性，他先用计算机生成了</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">N</font></font></font><font size="3">个</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">1</font></font></font><font size="3">到</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">1000</font></font></font><font size="3">之间的随机整数（</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">N</font></font><font face="宋体, SimSun"><font size="3">&le;</font></font><font face="Courier New, monospace"><font size="3">100</font></font></font><font size="3">），对于其中重复的数字，只保留一个，把其余相同的数去掉，不同的数对应着不同的学生的学号。然后再把这些数从小到大排序，按</font><font color="#000000"><font size="3">照</font></font><font size="3">排好的顺序去找同学做调查。请你协助明明完成&ldquo;去重&rdquo;与&ldquo;排序&rdquo;的工作。</font></p>
</p>]]></description>
<input><![CDATA[<p><style type="text/css">p { margin-bottom: 0.21cm; }</style>
<p align="LEFT" style="text-indent: 0.37cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font size="3">输入文件</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">random.in </font></font></font><font size="3">有</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">2</font></font></font><font size="3">行，第</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">1</font></font></font><font size="3">行为</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">1</font></font></font><font size="3">个正整数，表示所生成的随机数的个数：</font></p>
<p align="LEFT" style="text-indent: 0.37cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font face="Courier New, monospace"><font size="3">N</font></font></p>
<p align="LEFT" style="text-indent: 0.37cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font size="3">第</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">2</font></font></font><font size="3">行有</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">N</font></font></font><font size="3">个用空格隔开的正整数，为所产生的随机数。</font></p>
</p>]]></input> 
<output><![CDATA[<p><style type="text/css">p { margin-bottom: 0.21cm; }</style>
<p align="LEFT" style="text-indent: 0.37cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font size="3">输出文件</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">random.out </font></font></font><font size="3">也是</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">2</font></font></font><font size="3">行，第</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">1</font></font></font><font size="3">行为</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">1</font></font></font><font size="3">个正整数</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">M</font></font></font><font size="3">，表示不相同的随机数的个数。第</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">2</font></font></font><font size="3">行为</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">M</font></font></font><font size="3">个用空格隔开的正整数，为从小到大排好序的不相同的随机数。</font></p>
</p>]]></output>
<sample_input><![CDATA[10
20 40 32 67 40 20 89 300 400 15]]></sample_input>
<sample_output><![CDATA[8
15 20 32 40 67 89 300 400
]]></sample_output>
<test_input><![CDATA[10
20 40 321 67 40 20 89 301 407 15

]]></test_input>
<test_output><![CDATA[8
15 20 40 67 89 301 321 407
]]></test_output>
<test_input><![CDATA[20
20 40 321 677 40 20 89 301 407 515 40 321 67 40 20 89 301 407 15 499

]]></test_input>
<test_output><![CDATA[11
15 20 40 67 89 301 321 407 499 515 677
]]></test_output>
<test_input><![CDATA[30
120 40 321 677 40 321 67 40 20 89 301 407 15 499 440 240 89 301 407 515 40 321 67 40 20 89 301 407 15 499

]]></test_input>
<test_output><![CDATA[14
15 20 40 67 89 120 240 301 321 407 440 499 515 677
]]></test_output>
<test_input><![CDATA[40
5 491 440 240 89 301 407 515 403 321 120 40 321 677 402 321 67 40 20 89 301 407 15 492 440 240 89 301 407 515 40 321 67 410 20 9 301 407 15 499

]]></test_input>
<test_output><![CDATA[21
5 9 15 20 40 67 89 120 240 301 321 402 403 407 410 440 491 492 499 515 677
]]></test_output>
<test_input><![CDATA[50
607 420 321 67 40 20 89 301 407 135 15 4 447 241 89 301 407 515 410 321 120 40 321 667 400 321 67 40 209 89 301 407 15 499 440 240 89 301 407 515 40 321 637 410 20 8 301 407 15 49

]]></test_input>
<test_output><![CDATA[26
4 8 15 20 40 49 67 89 120 135 209 240 241 301 321 400 407 410 420 440 447 499 515 607 637 667

]]></test_output>
<test_input><![CDATA[60
89 301 407 515 40 321 120 40 821 675 673 671 670 67 40 20 891 301 407 15 151 97 4 241 893 301 407 515 840 311 150 420 321 677 40 321 67 40 20 81 303 407 15 499 440 240 89 301 407 515 40 321 67 410 20 89 301 407 15 499

]]></test_input>
<test_output><![CDATA[32
4 15 20 40 67 81 89 97 120 150 151 240 241 301 303 311 321 407 410 420 440 499 515 670 671 673 675 677 821 840 891 893

]]></test_output>
<test_input><![CDATA[70
302 457 215 315 437 447 231 189 301 407 89 306 407 515 40 321 120 40 321 617 627 637 679 67 430 230 8 303 408 125 15 497 447 241 89 301 402 515 40 321 120 40 321 677 40 327 67 40 20 89 301 407 15 499 440 240 89 301 407 515 40 321 67 410 20 89 301 407 15 498

]]></test_input>
<test_output><![CDATA[39
8 15 20 40 67 89 120 125 189 215 230 231 240 241 301 302 303 306 315 321 327 402 407 408 410 430 437 440 447 457 497 498 499 515 617 627 637 677 679

]]></test_output>
<test_input><![CDATA[80
407 84 341 408 525 41 322 220 40 321 302 45 215 315 437 447 231 189 304 404 8 301 407 515 40 321 120 40 321 617 637 679 779 767 40 20 89 301 707 815 15 497 447 241 89 301 407 515 40 321 120 40 321 677 40 321 67 40 20 89 301 407 15 499 440 240 89 301 407 515 40 321 67 410 20 89 301 407 15 498

]]></test_input>
<test_output><![CDATA[43
8 15 20 40 41 45 67 84 89 120 189 215 220 231 240 241 301 302 304 315 321 322 341 404 407 408 410 437 440 447 497 498 499 515 525 617 637 677 679 707 767 779 815

]]></test_output>
<test_input><![CDATA[90
7 2 315 437 447 231 189 301 407 8 407 84 341 408 525 41 322 220 40 321 302 457 215 315 437 447 231 189 301 407 89 301 407 515 40 321 120 40 321 679 678 676 659 67 409 201 899 801 407 185 5 497 447 241 89 301 407 515 40 321 120 490 321 677 40 321 67 40 20 891 301 407 15 499 440 240 89 301 407 515 40 321 67 410 20 89 301 407 15 498

]]></test_input>
<test_output><![CDATA[48
2 5 7 8 15 20 40 41 67 84 89 120 185 189 201 215 220 231 240 241 301 302 315 321 322 341 407 408 409 410 437 440 447 457 490 497 498 499 515 525 659 676 677 678 679 801 891 899

]]></test_output>
<test_input><![CDATA[8
20 40 321 67 40 40 89 15

]]></test_input>
<test_output><![CDATA[6
15 20 40 67 89 321

]]></test_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[NOIP2006]]></source>
</item>
<item>
<title><![CDATA[开心的金明]]></title>
<time_limit><![CDATA[1]]></time_limit>
<memory_limit><![CDATA[128]]></memory_limit>

<description><![CDATA[<p><style type="text/css">p { margin-bottom: 0.21cm; }</style>
<p align="LEFT" style="text-indent: 0.77cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font size="3">金明今天很开心，家里购置的新房就要领钥匙了，新房里有一间他自己专用的很宽敞的房间。更让他高兴的是，妈妈昨天对他说：&ldquo;你的房间需要购买哪些物品，怎么布置，你说了算，只要不超过</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">N</font></font></font><font size="3">元钱就行&rdquo;。今天一早金明就开始做预算，但是他想买的东西太多了，肯定会超过妈妈限定的</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">N</font></font></font><font size="3">元。于是，他把每件物品规定了一个重要度，分为</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">5</font></font></font><font size="3">等：用整数</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">1</font></font><font color="#000000"><font face="Courier New, monospace"><font size="3">~</font></font></font><font face="Courier New, monospace"><font size="3">5</font></font></font><font size="3">表示，第</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">5</font></font></font><font size="3">等最重要。他还从因特网上查到了每件物品的价格（都是整数元）。他希望在不超过</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">N</font></font></font><font size="3">元（可以等于</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">N</font></font></font><font size="3">元）的前提下，使每件物品的价格与重要度的乘积的总和最大。</font></p>
<p align="LEFT" style="text-indent: 0.77cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font size="3">设第</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">j</font></font></font><font size="3">件物品的价格为</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">v[j]</font></font></font><font size="3">，重要度为</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">w[j]</font></font></font><font size="3">，共选中了</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">k</font></font></font><font size="3">件物品，编号依次为</font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">j</font></font></font><font color="#000000"><sub><font face="Courier New, monospace"><font size="3">1</font></font></sub></font></font><font color="#000000"><font size="3">，</font></font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">j</font></font><sub><font face="Courier New, monospace"><font size="3">2</font></font></sub></font><font size="3">，&hellip;&hellip;，</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">j</font></font><sub><font face="Courier New, monospace"><font size="3">k</font></font></sub></font><font size="3">，则所求的总和为：</font></p>
<p align="LEFT" style="text-indent: 0.77cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3"><span lang="pl-PL">v[j</span></font></font><sub><font face="Courier New, monospace"><font size="3"><span lang="pl-PL">1</span></font></font></sub><font face="Courier New, monospace"><font size="3"><span lang="pl-PL">]*w[j</span></font></font><sub><font face="Courier New, monospace"><font size="3"><span lang="pl-PL">1</span></font></font></sub><font face="Courier New, monospace"><font size="3"><span lang="pl-PL">]+v[j</span></font></font><sub><font face="Courier New, monospace"><font size="3"><span lang="pl-PL">2</span></font></font></sub><font face="Courier New, monospace"><font size="3"><span lang="pl-PL">]*w[j</span></font></font><sub><font face="Courier New, monospace"><font size="3"><span lang="pl-PL">2</span></font></font></sub><font face="Courier New, monospace"><font size="3"><span lang="pl-PL">]+ </span></font></font><font face="宋体, SimSun"><font size="3">&hellip;</font></font><font face="Courier New, monospace"><font size="3"><span lang="pl-PL">+v[j</span></font></font><sub><font face="Courier New, monospace"><font size="3"><span lang="pl-PL">k</span></font></font></sub><font face="Courier New, monospace"><font size="3"><span lang="pl-PL">]*w[j</span></font></font><sub><font face="Courier New, monospace"><font size="3"><span lang="pl-PL">k</span></font></font></sub><font face="Courier New, monospace"><font size="3"><span lang="pl-PL">]</span></font></font></font><font size="3">。（其中</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">*</font></font></font><font size="3">为乘号）</font></p>
<p align="LEFT" style="text-indent: 0.77cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font size="3">请你帮助金明设计一个满足要求的购物单。</font></p>
</p>]]></description>
<input><![CDATA[<p><style type="text/css">p { margin-bottom: 0.21cm; }</style>
<p align="LEFT" style="text-indent: 0.19cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font size="3">输入文件</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">happy.in </font></font></font><font size="3">的第</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">1</font></font></font><font size="3">行，为两个正整数，用一个空格隔开：</font></p>
<p align="LEFT" style="text-indent: 0.37cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font face="Courier New, monospace"><font size="3">N m</font></font></p>
<p align="LEFT" style="text-indent: 0.37cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font size="3">（其中</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">N</font></font></font><font color="#000000"><font size="3">（</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">&lt;</font></font></font><font face="Courier New, monospace"><font size="3">30000</font></font></font><font size="3">）表示总钱数，</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">m</font></font></font><font size="3">（</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">&lt;25</font></font></font><font size="3">）为希望购买物品的个数。）</font></p>
<p align="LEFT" style="text-indent: 0.37cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font size="3">从第</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">2</font></font></font><font size="3">行到第</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">m+1</font></font></font><font size="3">行，第</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">j</font></font></font><font size="3">行给出了编号为</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">j-1</font></font></font><font size="3">的物品的基本数据，每行有</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">2</font></font></font><font size="3">个非负整数</font></p>
<p align="LEFT" style="text-indent: 0.37cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font face="Courier New, monospace"><font size="3">v p</font></font></p>
<p align="LEFT" style="text-indent: 0.37cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font size="3">（其中</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">v</font></font></font><font size="3">表示该物品的价格</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">(v&lt;=10000)</font></font></font><font size="3">，</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">p</font></font></font><font size="3">表示该物品的重要度</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">(1~5)</font></font></font><font size="3">）</font></p>
</p>]]></input> 
<output><![CDATA[<p><style type="text/css">p { margin-bottom: 0.21cm; }</style>
<p align="LEFT" style="text-indent: 0.19cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font size="3">输出文件</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">happy.out</font></font></font><font size="3">只有一个正整数，为不超过总钱数的物品的价格与重要度乘积的总和的最大值（</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">&lt;100000000</font></font></font><font size="3">）。</font></p>
</p>]]></output>
<sample_input><![CDATA[1000 5
800 2
400 5
300 5
400 3
200 2
]]></sample_input>
<sample_output><![CDATA[3900
]]></sample_output>
<test_input><![CDATA[2000 8
800 2
400 5
400 5
500 3
200 2
430 4
540 3
239 3
]]></test_input>
<test_output><![CDATA[7937
]]></test_output>
<test_input><![CDATA[3000 12
800 2
400 5
400 5
500 3
200 2
430 4
530 3
239 3
630 4
500 2
220 3
430 3
]]></test_input>
<test_output><![CDATA[11430
]]></test_output>
<test_input><![CDATA[4000 15
821 3
422 5
458 5
500 3
200 2
430 4
530 3
239 3
630 4
500 2
220 3
430 3
400 5
400 5
500 3
]]></test_input>
<test_output><![CDATA[16393
]]></test_output>
<test_input><![CDATA[5000 18
821 3
422 5
458 5
500 3
200 2
430 4
530 3
239 3
630 4
500 2
220 3
430 3
400 5
400 5
500 3
666 3
521 4
220 1
]]></test_input>
<test_output><![CDATA[19902
]]></test_output>
<test_input><![CDATA[20000 18
821 3
7422 5
458 5
500 3
200 2
430 4
530 3
239 3
3630 4
500 2
220 3
430 3
2400 5
400 5
500 3
666 3
2521 4
3220 1
]]></test_input>
<test_output><![CDATA[87935
]]></test_output>
<test_input><![CDATA[12000 18
2758 5
3500 3
1200 2
430 4
530 3
239 3
2630 4
500 2
1120 3
1430 3
1420 5
400 1
1500 3
666 3
521 4
2430 3
1400 2
3410 4
]]></test_input>
<test_output><![CDATA[51161
]]></test_output>
<test_input><![CDATA[18000 20
6758 5
3500 3
1200 2
430 4
530 3
239 3
2630 4
500 2
1120 3
1430 3
1420 5
400 4
1500 3
666 3
521 4
1220 1
2430 3
1400 2
3410 4
2520 3
]]></test_input>
<test_output><![CDATA[77744
]]></test_output>
<test_input><![CDATA[21000 23
2821 3
2422 5
6758 5
3500 3
2758 5
1200 2
430 4
530 3
239 3
2630 4
500 2
1120 3
1430 3
1420 5
400 4
1500 3
666 3
521 4
4220 1
2430 3
1400 2
3410 4
2520 3
]]></test_input>
<test_output><![CDATA[97071
]]></test_output>
<test_input><![CDATA[26000 24
6608 5
2821 3
4808 5
2821 3
422 5
3500 3
1200 2
430 4
3530 3
239 3
7730 4
500 2
120 3
3430 3
420 5
2500 3
2666 3
2521 4
3220 1
1430 3
1400 2
3410 4
2520 3
2500 2
]]></test_input>
<test_output><![CDATA[115934
]]></test_output>
<test_input><![CDATA[1200 5
800 2
400 5
400 5
500 3
200 2

]]></test_input>
<test_output><![CDATA[4400
]]></test_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[NOIP2006]]></source>
</item>
<item>
<title><![CDATA[Jam的计数法]]></title>
<time_limit><![CDATA[1]]></time_limit>
<memory_limit><![CDATA[128]]></memory_limit>

<description><![CDATA[<p><style type="text/css">p { margin-bottom: 0.21cm; }</style>
<p align="LEFT" style="text-indent: 0.74cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">Jam</font></font></font><font size="3">是个喜欢标新立异的科学怪人。他不使用阿拉伯数字计数，而是使用小写英文字母计数，他觉得这样做，会使世界更加丰富多彩。在他的计数法中，每个数字的位数都是相同的（使用相同个数的字母），英文字母按原先的顺序，排在前面的字母小于排在它后面的字母。我们把这样的&ldquo;数字&rdquo;称为</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">Jam</font></font></font><font size="3">数字。在</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">Jam</font></font></font><font size="3">数字中，每个字母互不相同，而且从左到右是严格递增的。每次，</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">Jam</font></font></font><font size="3">还指定使用字母的范围，例如，从</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">2</font></font></font><font size="3">到</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">10</font></font></font><font size="3">，表示只能使用</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">{b,c,d,e,f,g,h,i,j}</font></font></font><font size="3">这些字母。如果再规定位数为</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">5</font></font></font><font size="3">，那么，紧接在</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">Jam</font></font></font><font size="3">数字&ldquo;</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">bdfij</font></font><font face="宋体, SimSun"><font size="3">&rdquo;</font></font></font><font size="3">之后的数字应该是&ldquo;</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">bdghi</font></font><font face="宋体, SimSun"><font size="3">&rdquo;</font></font></font><font size="3">。（如果我们用</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">U</font></font></font><font size="3">、</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">V</font></font></font><font size="3">依次表示</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">Jam</font></font></font><font size="3">数字&ldquo;</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">bdfij</font></font><font face="宋体, SimSun"><font size="3">&rdquo;</font></font></font><font size="3">与&ldquo;</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">bdghi</font></font><font face="宋体, SimSun"><font size="3">&rdquo;</font></font></font><font size="3">，则</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">U&lt;V&lt; span&gt;</font></font></font><font size="3">，且不存在</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">Jam</font></font></font><font size="3">数字</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">P</font></font></font><font size="3">，使</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">U&lt;P&lt;V&lt; span&gt;</font></font></font><font size="3">）。你的任务是：对于从文件读入的一个</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">Jam</font></font></font><font size="3">数字，按顺序输出紧接在后面的</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">5</font></font></font><font size="3">个</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">Jam</font></font></font><font size="3">数字，如果后面没有那么多</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">Jam</font></font></font><font size="3">数字，那么有几个就输出几个。</font></p>
<p align="LEFT" style="margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font size="3"><br />
</font></p>
</p>]]></description>
<input><![CDATA[<p><style type="text/css">p { margin-bottom: 0.21cm; }</style>
<p align="LEFT" style="text-indent: 0.19cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font size="3">输入文件</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">counting.in </font></font></font><font size="3">有</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">2</font></font></font><font size="3">行，第</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">1</font></font></font><font size="3">行为</font><font face="DejaVu Serif, serif"><font face="Courier New, monospace"><font size="3">3</font></font></font><font size="3">个正整数，用一个空格隔开：</font></p>
<p align="LEFT" style="text-indent: 0.37cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font color="#000000"><font face="Courier New, monospace"><font size="3">s t w</font></font></font></p>
<p align="LEFT" style="text-indent: 0.37cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font color="#000000"><font size="3">（其中</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">s</font></font></font></font><font color="#000000"><font size="3">为所使用的最小的字母的序号，</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">t</font></font></font></font><font color="#000000"><font size="3">为所使用的最大的字母的序号。</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">w</font></font></font></font><font color="#000000"><font size="3">为数字的位数，这</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">3</font></font></font></font><font color="#000000"><font size="3">个数满足：</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">1</font></font></font><font color="#000000"><font face="宋体, SimSun"><font size="3">&le;</font></font></font><font color="#000000"><font face="Courier New, monospace"><font size="3">s&lt;T&lt; span&gt;</font></font></font><font color="#000000"><font face="宋体, SimSun"><font size="3">&le;</font></font></font><font color="#000000"><font face="Courier New, monospace"><font size="3">26, 2</font></font></font><font color="#000000"><font face="宋体, SimSun"><font size="3">&le;</font></font></font><font color="#000000"><font face="Courier New, monospace"><font size="3">w</font></font></font><font color="#000000"><font face="宋体, SimSun"><font size="3">&le;</font></font></font><font color="#000000"><font face="Courier New, monospace"><font size="3">t-s </font></font></font></font><font color="#000000"><font size="3">）</font></font><font color="#000000"><font size="3"> </font></font></p>
<p align="LEFT" style="text-indent: 0.37cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font color="#000000"><font size="3">第</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">2</font></font></font></font><font color="#000000"><font size="3">行为具有</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">w</font></font></font></font><font color="#000000"><font size="3">个小写字母的字符串，为一个符合要求的</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">Jam</font></font></font></font><font color="#000000"><font size="3">数字。</font></font></p>
<p align="LEFT" style="text-indent: 0.37cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font color="#000000"><font size="3">所给的数据都是正确的，不必验证。</font></font></p>
</p>]]></input> 
<output><![CDATA[<p><style type="text/css">p { margin-bottom: 0.21cm; }</style>
<p align="LEFT" style="text-indent: 0.74cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font color="#000000"><font size="3">输出文件</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">counting.out </font></font></font></font><font color="#000000"><font size="3">最多为</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">5</font></font></font></font><font color="#000000"><font size="3">行，为紧接在输入的</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">Jam</font></font></font></font><font color="#000000"><font size="3">数字后面的</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">5</font></font></font></font><font color="#000000"><font size="3">个</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">Jam</font></font></font></font><font color="#000000"><font size="3">数字，如果后面没有那么多</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">Jam</font></font></font></font><font color="#000000"><font size="3">数字，那么有几个就输出几个。每行只输出一个</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">Jam</font></font></font></font><font color="#000000"><font size="3">数字，是由</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">w</font></font></font></font><font color="#000000"><font size="3">个小写字母组成的字符串，不要有多余的空格。</font></font></p>
</p>]]></output>
<sample_input><![CDATA[2 10 5
bdfij
]]></sample_input>
<sample_output><![CDATA[bdghi
bdghj
bdgij
bdhij
befgh
]]></sample_output>
<test_input><![CDATA[2 10 5
cefij

]]></test_input>
<test_output><![CDATA[ceghi
ceghj
cegij
cehij
cfghi
]]></test_output>
<test_input><![CDATA[2 14 6
defijm

]]></test_input>
<test_output><![CDATA[defijn
defikl
defikm
defikn
defilm
]]></test_output>
<test_input><![CDATA[2 14 8
bdefhijm

]]></test_input>
<test_output><![CDATA[bdefhijn
bdefhikl
bdefhikm
bdefhikn
bdefhilm
]]></test_output>
<test_input><![CDATA[5 20 8
fhijmpqt

]]></test_input>
<test_output><![CDATA[fhijmprs
fhijmprt
fhijmpst
fhijmqrs
fhijmqrt
]]></test_output>
<test_input><![CDATA[5 22 10
efhijmpqtu

]]></test_input>
<test_output><![CDATA[efhijmpqtv
efhijmpquv
efhijmprst
efhijmprsu
efhijmprsv
]]></test_output>
<test_input><![CDATA[5 22 14
efhijklmpqrtuv

]]></test_input>
<test_output><![CDATA[efhijklmpqstuv
efhijklmprstuv
efhijklmqrstuv
efhijklnopqrst
efhijklnopqrsu
]]></test_output>
<test_input><![CDATA[5 24 14
efhijklmpqrtuw

]]></test_input>
<test_output><![CDATA[efhijklmpqrtux
efhijklmpqrtvw
efhijklmpqrtvx
efhijklmpqrtwx
efhijklmpqruvw
]]></test_output>
<test_input><![CDATA[4 24 17
dfghijklmopqrtuvw

]]></test_input>
<test_output><![CDATA[dfghijklmopqrtuvx
dfghijklmopqrtuwx
dfghijklmopqrtvwx
dfghijklmopqruvwx
dfghijklmopqstuvw
]]></test_output>
<test_input><![CDATA[2 24 19
cdfghijklmopqrtuvwx

]]></test_input>
<test_output><![CDATA[cdfghijklmopqstuvwx
cdfghijklmoprstuvwx
cdfghijklmoqrstuvwx
cdfghijklmpqrstuvwx
cdfghijklnopqrstuvw
]]></test_output>
<test_input><![CDATA[2 9 4
bchi
]]></test_input>
<test_output><![CDATA[bdef
bdeg
bdeh
bdei
bdfg
]]></test_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[NOIP2006]]></source>
</item>
<item>
<title><![CDATA[数列]]></title>
<time_limit><![CDATA[1]]></time_limit>
<memory_limit><![CDATA[128]]></memory_limit>

<description><![CDATA[<p><style type="text/css">p { margin-bottom: 0.21cm; }</style>
<p align="LEFT" style="text-indent: 0.74cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font color="#000000"><font size="3">给定一个正整数</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">k(3</font></font></font><font color="#000000"><font face="宋体, SimSun"><font size="3">&le;</font></font></font><font color="#000000"><font face="Courier New, monospace"><font size="3">k</font></font></font><font color="#000000"><font face="宋体, SimSun"><font size="3">&le;</font></font></font><font color="#000000"><font face="Courier New, monospace"><font size="3">15),</font></font></font></font><font color="#000000"><font size="3">把所有</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">k</font></font></font></font><font color="#000000"><font size="3">的方幂及所有有限个互不相等的</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">k</font></font></font></font><font color="#000000"><font size="3">的方幂之和构成一个递增的序列，例如，当</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">k=3</font></font></font></font><font color="#000000"><font size="3">时，这个序列是：</font></font></p>
<p align="LEFT" style="text-indent: 0.74cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">1</font></font></font></font><font color="#000000"><font size="3">，</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">3</font></font></font></font><font color="#000000"><font size="3">，</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">4</font></font></font></font><font color="#000000"><font size="3">，</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">9</font></font></font></font><font color="#000000"><font size="3">，</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">10</font></font></font></font><font color="#000000"><font size="3">，</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">12</font></font></font></font><font color="#000000"><font size="3">，</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">13</font></font></font></font><font color="#000000"><font size="3">，&hellip;</font></font></p>
<p align="LEFT" style="text-indent: 0.74cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font color="#000000"><font size="3">（该序列实际上就是：</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">3</font></font></font><font color="#000000"><sup><font face="Courier New, monospace"><font size="3">0</font></font></sup></font></font><font color="#000000"><font size="3">，</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">3</font></font></font><font color="#000000"><sup><font face="Courier New, monospace"><font size="3">1</font></font></sup></font></font><font color="#000000"><font size="3">，</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">3</font></font></font><font color="#000000"><sup><font face="Courier New, monospace"><font size="3">0</font></font></sup></font><font color="#000000"><font face="Courier New, monospace"><font size="3">+3</font></font></font><font color="#000000"><sup><font face="Courier New, monospace"><font size="3">1</font></font></sup></font></font><font color="#000000"><font size="3">，</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">3</font></font></font><font color="#000000"><sup><font face="Courier New, monospace"><font size="3">2</font></font></sup></font></font><font color="#000000"><font size="3">，</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">3</font></font></font><font color="#000000"><sup><font face="Courier New, monospace"><font size="3">0</font></font></sup></font><font color="#000000"><font face="Courier New, monospace"><font size="3">+3</font></font></font><font color="#000000"><sup><font face="Courier New, monospace"><font size="3">2</font></font></sup></font></font><font color="#000000"><font size="3">，</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">3</font></font></font><font color="#000000"><sup><font face="Courier New, monospace"><font size="3">1</font></font></sup></font><font color="#000000"><font face="Courier New, monospace"><font size="3">+3</font></font></font><font color="#000000"><sup><font face="Courier New, monospace"><font size="3">2</font></font></sup></font></font><font color="#000000"><font size="3">，</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">3</font></font></font><font color="#000000"><sup><font face="Courier New, monospace"><font size="3">0</font></font></sup></font><font color="#000000"><font face="Courier New, monospace"><font size="3">+3</font></font></font><font color="#000000"><sup><font face="Courier New, monospace"><font size="3">1</font></font></sup></font><font color="#000000"><font face="Courier New, monospace"><font size="3">+3</font></font></font><font color="#000000"><sup><font face="Courier New, monospace"><font size="3">2</font></font></sup></font></font><font color="#000000"><font size="3">，&hellip;）</font></font></p>
<p align="LEFT" style="text-indent: 0.74cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font color="#000000"><font size="3">请你求出这个序列的第</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">N</font></font></font></font><font color="#000000"><font size="3">项的值（用</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">10</font></font></font></font><font color="#000000"><font size="3">进制数表示）。</font></font></p>
<p align="LEFT" style="text-indent: 0.74cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font color="#000000"><font size="3">例如，对于</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">k=3</font></font></font></font><font color="#000000"><font size="3">，</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">N=100</font></font></font></font><font color="#000000"><font size="3">，正确答案应该是</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">981</font></font></font></font><font color="#000000"><font size="3">。</font></font></p>
</p>]]></description>
<input><![CDATA[<p><style type="text/css">p { margin-bottom: 0.21cm; }</style>
<p align="LEFT" style="text-indent: 0.19cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font color="#000000"><font size="3">输入文件</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">sequence.in </font></font></font></font><font color="#000000"><font size="3">只有</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">1</font></font></font></font><font color="#000000"><font size="3">行，为</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">2</font></font></font></font><font color="#000000"><font size="3">个正整数，用一个空格隔开：</font></font></p>
<p align="LEFT" style="text-indent: 0.37cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font color="#000000"><font face="Courier New, monospace"><font size="3">k N</font></font></font></p>
<p align="LEFT" style="text-indent: 0.37cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font color="#000000"><font size="3">（</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">k</font></font></font></font><font color="#000000"><font size="3">、</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">N</font></font></font></font><font color="#000000"><font size="3">的含义与上述的问题描述一致，且</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">3</font></font></font><font color="#000000"><font face="宋体, SimSun"><font size="3">&le;</font></font></font><font color="#000000"><font face="Courier New, monospace"><font size="3">k</font></font></font><font color="#000000"><font face="宋体, SimSun"><font size="3">&le;</font></font></font><font color="#000000"><font face="Courier New, monospace"><font size="3">15</font></font></font></font><font color="#0000ff"><font size="3">，</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">10</font></font></font><font color="#000000"><font face="宋体, SimSun"><font size="3">&le;</font></font></font><font color="#000000"><font face="Courier New, monospace"><font size="3">N</font></font></font><font color="#000000"><font face="宋体, SimSun"><font size="3">&le;</font></font></font><font color="#000000"><font face="Courier New, monospace"><font size="3">1000</font></font></font></font><font color="#000000"><font size="3">）。</font></font></p>
</p>]]></input> 
<output><![CDATA[<p><style type="text/css">p { margin-bottom: 0.21cm; }</style>
<p align="LEFT" style="text-indent: 0.74cm; margin-top: 0.49cm; margin-bottom: 0.49cm; line-height: 0.64cm; widows: 2; orphans: 2;"><font color="#000000"><font size="3">输出文件</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">sequence.out </font></font></font></font><font color="#000000"><font size="3">为计算结果，是一个正整数（在所有的测试数据中，结果均不超过</font></font><font face="DejaVu Serif, serif"><font color="#000000"><font face="Courier New, monospace"><font size="3">2.1*10</font></font></font><font color="#000000"><sup><font face="Courier New, monospace"><font size="3">9</font></font></sup></font></font><font color="#000000"><font size="3">）。（整数前不要有空格和其他符号）。</font></font></p>
</p>]]></output>
<sample_input><![CDATA[3 100
]]></sample_input>
<sample_output><![CDATA[981
]]></sample_output>
<test_input><![CDATA[5 120
]]></test_input>
<test_output><![CDATA[19500
]]></test_output>
<test_input><![CDATA[7 130
]]></test_input>
<test_output><![CDATA[823550
]]></test_output>
<test_input><![CDATA[7 290
]]></test_input>
<test_output><![CDATA[5781615
]]></test_output>
<test_input><![CDATA[8 991
]]></test_input>
<test_output><![CDATA[153358921
]]></test_output>
<test_input><![CDATA[9 900
]]></test_input>
<test_output><![CDATA[435250260
]]></test_output>
<test_input><![CDATA[9 1000
]]></test_input>
<test_output><![CDATA[435841398
]]></test_output>
<test_input><![CDATA[11 500
]]></test_input>
<test_output><![CDATA[235793426
]]></test_output>
<test_input><![CDATA[10 1000
]]></test_input>
<test_output><![CDATA[1111101000
]]></test_output>
<test_input><![CDATA[13 600
]]></test_input>
<test_output><![CDATA[2019422348
]]></test_output>
<test_input><![CDATA[4 100
]]></test_input>
<test_output><![CDATA[5136
]]></test_output>
<hint><![CDATA[]]></hint>
<source><![CDATA[NOIP2006]]></source>
</item>
</fps>