贪心——cf708b
2024-10-07 17:20:17
先求0,1的个数,然后贪心输出01即可
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a,b,c,d,tot1,tot0;
int main(){
cin>>a>>b>>c>>d;
//a=0,b=0的情况优先考虑
if(!a && !b && !c && !d){
puts("");return ;
}
//判断a=0的情况
if(!a&&!b&&!c)tot0=;else tot0=;
//判断d==0的情况
if(!d&&!b&&!c)tot1=;else tot1=; if(a)tot0=(int)(sqrt(a*))+;
if(d)tot1=(int)(sqrt(d*))+; if(tot0*(tot0-)/!=a || tot1*(tot1-)/!=d || tot0*tot1!=b+c){
puts("Impossible");return ;
} while(b){
if(b>=tot1){
cout<<;
b-=tot1;
tot0--;
}
else if(c>=tot0){
cout<<;
c-=tot0;
tot1--;
}
}while(tot1)cout<<,tot1--;
while(tot0)cout<<,tot0--; }
最新文章
- [转载]两个半小时学会Perl
- XPah学习
- wpf msdn在线地址http://msdn.microsoft.com/zh-cn/library/ms752324(v=vs.110).aspx
- Socket 学习(三).2 udp 穿透 服务端 与 客户端 通讯
- Hadoop -YARN 应用程序设计概述
- HTML中判断手机是否安装某APP,跳转或下载该应用
- angular router ui bug !
- CSS3总结一:border(边框)
- 解决hash冲突的三个方法
- KFCM算法的matlab程序
- 推荐10本C#编程的最佳书籍
- PGAdmin 4使用笔记
- springboot-28-security(一)用户角色控制
- 子元素scroll父元素容器不跟随滚动JS实现
- idea 设置
- Linux命令-目录处理命令:mv
- CXCommon.h工具类
- Linux安装vsftpd
- 关于PDO取得结果集的数据类型为string的问题
- CSS知识之 background-position 用法详细介绍
热门文章
- QTcpSocket学习
- SysTick功能总结
- BZOJ 3207: 花神的嘲讽计划Ⅰ(莫队+哈希)
- [NOIP模拟测试38]题解
- 远程桌面发生身份验证错误,要求的函数不受支持【WIN10家庭】或【专业版】--解决办法
- .NET Core开源组件:后台任务利器之Hangfire 转载 https://www.cnblogs.com/chenug/p/6655636.html
- Newline required at end of file but not found
- 阻抗匹配 及 SI9000 使用
- HDU4578-Transformation-线段树的加、乘、变、次方操作
- Scrapy框架: pipelines.py设置