题目链接

用火柴棍拼出最大的数,思维题,最后发现暴力1e7刚刚不会超时。

就是看如果这个位置放置尽可能大的数,剩余的火柴数够不够或者多不多。

够不够就是lefts>=leftn*2,多不多就是lefts<=leftn*7。

#include <bits/stdc++.h>
using namespace std;
int a[]={,,,,,,,,,};
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int len;
char c[];
scanf("%d%s",&len,c);
int sum=;
for(int i=;i<len;i++)
sum+=a[c[i]-''];
for(int i=;i<len;i++) {
for(int j=;j>=;j--) {
int lefts = sum-a[j];
int leftn = len-i-;
//printf("%d\n",lefts);
if(leftn*<=lefts&&lefts<=leftn*) {
putchar(''+j);
sum = lefts;
break;
}
}
}
puts("");
}
return ;
}

Gym - 101102B的更多相关文章

  1. Gym 101102B The Little Match Girl(贪心+规律)

    这个题目的做法不止一种,solve1:每个数字使用的火柴棒都在2~7之间,而且是连续的,就是2-7之前没有空着的数.这样就有一个结论,在下界为l,上界为r的情况下,假设有n个数,那么火柴棒总数一定在n ...

  2. Codeforces Gym - 101102B - The Little Match Girl

    B. The Little Match Girl time limit per test 1 second memory limit per test 256 megabytes input stan ...

  3. ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力

     Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS     Memory Limit:65536KB     64bit IO Fo ...

  4. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  5. ACM: Gym 101047E Escape from Ayutthaya - BFS

    Gym 101047E Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I6 ...

  6. ACM: Gym 101047B Renzo and the palindromic decoration - 手速题

     Gym 101047B  Renzo and the palindromic decoration Time Limit:2000MS     Memory Limit:65536KB     64 ...

  7. Gym 101102J---Divisible Numbers(反推技巧题)

    题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...

  8. Gym 100917J---Judgement(01背包+bitset)

    题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...

  9. Gym 100917J---dir -C(RMQ--ST)

    题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...

随机推荐

  1. 分形之概率学下的green tree

         今天做的是分形之随机概率,可以和以前做的那个抛色子的做法非常相似,抛色子是用随机点数控制图形,今天做的树叶图形只是用概率的做法去控制图形而已,做法是如出一辙的: //图形界面 package ...

  2. Codeforces Round #380(div 2)

    A. 题意:给你一串字符串(<=100),将ogo ogogo ogogogo ogogogogo……这种全部缩成***,输出缩后的字符串 分析:第一遍扫对于那些go的位置,记录下next[i] ...

  3. SetEnvlfNoCase 记录从自己网站之外传来的请求

    <FilesMatch \.(jpg|gif|png)$> SetEnvIfNoCase Referer "^http://www.example.com/" loca ...

  4. shell知识点小结

    目录 引言 shell中的数组 数组的定义 数组的使用 实际的例子 shell中大小的比较 shell中的括号 shell中函数的定义 杂项知识点 字符串转数组 常用判断标志 linux后台运行相关 ...

  5. Linux 远程复制文件

    Linux 远程复制文件 如果想把机器A上面的dir目录下面的所有文件复制到机器B的dir目录下,我们可以使用nc命令来完成 在机器A的dir目录下面执行: tar -czf - * | nc -l ...

  6. unsigned无符号、有符号类型的符号拓展

    先看一段代码 #include <stdio.h> main(){ unsigned ; char b = a; printf("%d %d",a,b); ; } a输 ...

  7. centos 软件包安装与管理

    http://rpmfind.net/linux/RPM/index.html http://pkgs.org/ https://sourceforge.net/

  8. Web jquery表格组件 JQGrid 的使用 - 4.JQGrid参数、ColModel API、事件及方法

    系列索引 Web jquery表格组件 JQGrid 的使用 - 从入门到精通 开篇及索引 Web jquery表格组件 JQGrid 的使用 - 4.JQGrid参数.ColModel API.事件 ...

  9. 网络中两台主机的通信过程(TCP)

    两台主机通信有两种情况:1.在同一网段中 2.不在同一网段中 (1.)在同一网段的通信过程 主机在应用层上的操作: TCP/IP协议上tcp的端口对应的各种应用程序,客户机要访问某个应用程序就会要求打 ...

  10. 阿里巴巴分布式服务框架dubbo学习笔记

    Dubbo是什么? Dubbo是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案.简单的说,dubbo就是个服务框架,如果没有分布式的需求,其实是不需要用的 ...