Codeforces Round #742 (Div. 2)题解
链接
\(A,B\)题签到,就完了。
\(C\)题,考虑进位时多进一位,由于是隔一位进的,所以可以发现奇数位和偶数位是相互独立的,那么我们就把奇数位和偶数位单独拉出来组成数字例如:34789,我们单独拉出来的奇数位为:379,单独拉出来的偶数位为48,这样的话我们再将这两个数按照十进制算法正常相加的个数即可。考虑一个数\(x\),若两个有序实数对相加的个数为\(x+1\),那我们最终的答案就是\((x_奇+1)\times(x_偶+1)-2\),因为最后的数不能拆成(n,0)和(0,n),除去这两种。
//不等,不问,不犹豫,不回头.
#include<bits/stdc++.h>
#define _ 0
#define ls p<<1
#define db double
#define rs p<<1|1
#define P 1000000007
#define ll long long
#define INF 1000000000
#define get(x) x=read()
#define PLI pair<ll,int>
#define PII pair<int,int>
#define ull unsigned long long
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define rep(x,y,z) for(int x=y;x<=z;++x)
#define fep(x,y,z) for(int x=y;x>=z;--x)
#define go(x) for(int i=link[x],y=a[i].y;i;y=a[i=a[i].next].y)
using namespace std;
inline int read()
{
int x=0,ff=1;
char ch=getchar();
while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return x*ff;
}
int main()
{
//freopen("1.in","r",stdin);
int get(T);
while(T--)
{
int get(n);
ll x1=0,x2=0;
int s=1e9;
rep(i,1,10)
{
if(i%2==1) x1=x1*10+n/s;
else x2=x2*10+n/s;
n%=s;s/=10;
}
putl((x1+1)*(x2+1)-2);
}
return (0^_^0);
}
//以吾之血,铸吾最后的亡魂.
关于\(D\)题,
简化题意就是给定你一个数字\(s\)和\(n\),让你构造一个长度为\(n\)的序列,使得序列中的元素和为\(s\)。并且使得这个序列中的元素转化为\(11\)进制后的和最大。
发现我们最优的情况就是使得拆开后的数字在各个数位上相加任然和原数相等,但若不等的话,我们只能将拆开了。贪心的从低位向高位拆就行。
//不等,不问,不犹豫,不回头.
#include<bits/stdc++.h>
#define _ 0
#define ls p<<1
#define db double
#define rs p<<1|1
#define P 1000000007
#define ll long long
#define INF 1000000000
#define get(x) x=read()
#define PLI pair<ll,int>
#define PII pair<int,int>
#define ull unsigned long long
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define rep(x,y,z) for(int x=y;x<=z;++x)
#define fep(x,y,z) for(int x=y;x>=z;--x)
#define go(x) for(int i=link[x],y=a[i].y;i;y=a[i=a[i].next].y)
using namespace std;
ll p[20];
inline int read()
{
int x=0,ff=1;
char ch=getchar();
while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return x*ff;
}
int main()
{
//freopen("1.in","r",stdin);
int get(T);
while(T--)
{
ll get(s),get(n);
ll now=s,cnt=0;
rep(i,1,10)
{
p[i]=now%10;
now/=10;
cnt+=p[i];
}
while(cnt<n)
{
rep(i,2,10)
{
if(p[i])
{
p[i]--;
p[i-1]+=10;
cnt+=9;
break;
}
}
}
ll pz=1;n--;
rep(i,1,10)
{
rep(j,1,min(n,p[i])) printf("%lld ",1*pz);
s-=min(n,p[i])*pz;n-=min(n,p[i]);
pz*=10;
}
printf("%lld\n",s);
}
return (0^_^0);
}
//以吾之血,铸吾最后的亡魂.
Codeforces Round #742 (Div. 2)题解的更多相关文章
- Codeforces Round #182 (Div. 1)题解【ABCD】
Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...
- Codeforces Round #608 (Div. 2) 题解
目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...
- Codeforces Round #525 (Div. 2)题解
Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # inclu ...
- Codeforces Round #528 (Div. 2)题解
Codeforces Round #528 (Div. 2)题解 A. Right-Left Cipher 很明显这道题按题意逆序解码即可 Code: # include <bits/stdc+ ...
- Codeforces Round #466 (Div. 2) 题解940A 940B 940C 940D 940E 940F
Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权 ...
- Codeforces Round #677 (Div. 3) 题解
Codeforces Round #677 (Div. 3) 题解 A. Boring Apartments 题目 题解 简单签到题,直接数,小于这个数的\(+10\). 代码 #include &l ...
- Codeforces Round #665 (Div. 2) 题解
Codeforces Round #665 (Div. 2) 题解 写得有点晚了,估计都官方题解看完切掉了,没人看我的了qaq. 目录 Codeforces Round #665 (Div. 2) 题 ...
- Codeforces Round #160 (Div. 1) 题解【ABCD】
Codeforces Round #160 (Div. 1) A - Maxim and Discounts 题意 给你n个折扣,m个物品,每个折扣都可以使用无限次,每次你使用第i个折扣的时候,你必须 ...
- Codeforces Round #383 (Div. 2) 题解【ABCDE】
Codeforces Round #383 (Div. 2) A. Arpa's hard exam and Mehrdad's naive cheat 题意 求1378^n mod 10 题解 直接 ...
随机推荐
- Python中with...as...的用法详解
简介 with是从Python2.5引入的一个新的语法,它是一种上下文管理协议,目的在于从流程图中把 try,except 和finally 关键字和资源分配释放相关代码统统去掉,简化try-.exc ...
- 离散化模板题 II ——重复元素离散化后的数字不相同
离散化模板题 II --重复元素离散化后的数字不相同 题目描述 现有数列A1, A2, ⋯, An,数列中可能有重复元素. 现在要求输出该数列的离散化数列,重复元素离散化后的数字不相同. 输入 第一行 ...
- centos7 未启用swap导致内存使用率过高。
情况描述: 朋友在阿里云上有一台系统为CentOS7的VPS,内存为2GB,用于平时开发自己的项目时测试使用: 他在上面运行了5个docker实例,运行java程序:还有一个mysql服务: 上述5个 ...
- golang 开发环境 配置 go语言 liteIDE
Mac: * 下载go安装包 go语言中文网 ** 通过源码编译安装需要先安装go1.4 wget https://studygolang.com/dl/golang/go1.10.3.src.tar ...
- photoshop CS6打不开提示请卸载并重新安装该程序
运行Photoshop.exe时,提示错误: 解决方案: 以管理员身份运行该exe文件
- jzoj4496-[GDSOI2016]互补约数【莫比乌斯反演】
正题 题目链接:https://gmoj.net/senior/#main/show/4496 题目大意 给出\(n\),定义 \[f(i)=\sum_{d|i}gcd(d,\frac{i}{d}) ...
- Redis新旧复制
在Redis中,用户可以通过执行SALVEOF命令,让一个服务器去复制另一个服务器. 127.0.0.1:12345> SLAVEOF 127.0.0.1 6379 OK 6379的奴隶是123 ...
- aizhan查询旁IP网站脚本
<?php print_r("-------------------------\r\n"); print_r("-------爱站旁站查询------\r\n&q ...
- 自然语言处理标注工具——Brat(安装、测试、使用)
一.Brat标注工具安装 1.安装条件: (1)运行于Linux系统(window系统下虚拟机内linux系统安装也可以) (2)目前brat最新版本(v1.3p1)仅支持python2版本运行使用( ...
- 在 ASP.NET Core 中自动启用 CAP 事务
本篇文章旨在描述如何在 ASP.NET Core项目中并以一种简便的方式启用CAP事务,因为在我们的示例中都是直接演示比较直观的方式,没有进行封装,有些初学者同学不太会,找到问我如何封装,本篇文章主要 ...