2017.1.21【初中部 GDKOI】模拟赛B组 国色天香 题解
来源:互联网 发布:淘宝商城饰品店 编辑:程序博客网 时间:2024/04/30 04:02
原题:
http://172.16.0.132/senior/#contest/show/1912/2
题目描述:
庭前芍药妖无格,池上芙蕖净少情。唯有牡丹真国色,花开时节动京城。
——唐·刘禹锡《赏牡丹》
芍药花再红终究妖艳无格。终不及牡丹,国色天香。
——乌拉那拉氏宜修
华妃总是想要用自己的气焰打压皇后,正好有一天,皇上有兴趣来玩一个火柴游戏,让华妃和皇后都来参与。规则如下:
这是火柴所形成9个数字的方式,每个数字所需的火柴数量不一样。现在皇上给每个人发了N根火柴,华妃要摆出其所能摆出最小的数,而皇后则需要摆出其所能摆出的最大的数。当然,皇上是不容糊弄的,前导0或者摆出不规则的数字什么的都算是作弊。获胜者的奖励则是皇上今晚会翻她的牌子。现在皇后与华妃都使出浑身解数,而在一旁观看的甄嬛则想尽快知道答案。
输入:
输入包括若干组数据。第一行为一个数字T,表示皇上会进行T次游戏。
接下来一行,每行一个正整数N,表示火柴的数量。
输出:
T行,每组数据包括一行,分别为皇后所能摆出的最优值以及华妃所能摆出的最优值。
样例输入:
1
2
样例输出:
1 1
样例解释:
两根火柴只能摆出数字1,因此华妃和皇后的答案均为1.
分析:
贪心即可;
实现:
var n,t,m:longint;begin readln(t); while t>0 do begin readln(n); if n<>1 then begin m:=n; if m mod 2=1 then begin write(7); dec(m,3) end; while m>0 do begin write(1);dec(m,2) end; write(' '); case n mod 7 of 1:begin write(10); dec(n,8); end; 2:begin write(1); dec(n,2) end; 3: begin if n=3 then begin write(7); dec(n,3) end else if n=10 then begin write(22); dec(n,10) end else begin write(200); dec(n,17) end; end; 4: begin if n=4 then begin write(4); dec(n,4) end else begin write(20); dec(n,11) end; end; 5:begin write(2); dec(n,5) end; 6:begin write(6); dec(n,6) end; end; while n>0 do begin write(8); dec(n,7) end; end; writeln; dec(t); end;end.
0 0
- 2017.1.21【初中部 GDKOI】模拟赛B组 国色天香 题解
- 2017.1.13【初中部 GDKOI】模拟赛B组 逆光 题解
- 2017.1.14【初中部 GDKOI】模拟赛B组题解
- 2017.1.19【初中部 GDKOI】模拟赛B组 开灯 题解
- 2017.1.19【初中部 GDKOI】模拟赛B组 长方形 题解
- 2017.1.21【初中部 GDKOI】模拟赛B组 树的连通性 题解
- 2017.1.21【初中部 GDKOI】模拟赛B组 逻辑的连通性 题解
- 2017.2.09【初中部 GDKOI】模拟赛B组 昵称 题解
- 2017.2.10【初中部 GDKOI】模拟赛B组题解
- 2017.2.11【初中部 GDKOI】模拟赛B组题解
- 2017.2.11【初中部 GDKOI】模拟赛B组题解
- 2017.1.21【初中部 GDKOI】模拟赛B组
- 2017.1.13【初中部 GDKOI】模拟赛B组 我要的幸福 题解
- 2017.1.13【初中部 GDKOI】模拟赛B组 天黑黑 题解
- 2017.1.14【初中部 GDKOI】模拟赛B组 Mooo Moo 题解
- 2017.1.14【初中部 GDKOI】模拟赛B组 心灵终结 题解
- 2017.1.14【初中部 GDKOI】模拟赛B组 Watering the Fields 题解
- 2017.1.14【初中部 GDKOI】模拟赛B组 Mooo Moo 题解
- android 复制文字到剪贴板
- 用内存映射文件实现进程间通信
- The CATALINA_HOME environment variable is not defined correctly
- 使用C语言的struct来实现C++的class
- antcall的 用法
- 2017.1.21【初中部 GDKOI】模拟赛B组 国色天香 题解
- PE Binary File Analysis in the browser, without a backend.
- 链接出现多重定义错误
- js上传预览 兼容全部
- string转wchar_t (WCHAR)
- pat-bl-1041
- 设计模式之抽象工厂和工厂方法
- 责任链模式
- 装饰配器模式