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 题解 直接 ...
随机推荐
- 【OI】C++STL初步 排序与检索
从紫皮书过来的,但是书中内容讲的比较简洁,做一点补充笔记. 一.排序(sort函数) 头文件:<algorithm> 语法:sort(start,end,cmp); start,end必须 ...
- phpstorm一直 updating indices刷新
解决方法: File-> 选中 Invalidate Caches/Restart ->选中 Invalidate Caches/Restart
- DEDEcms手机网站添加详情内页上一页/下一页的翻页功能
修改文件include/arc.archives.class.php文件. 1.搜索 function GetPreNext($gtype='') 2.将这个函数的所有内容替换为 function G ...
- Shell系列(38)- 数组操作→取值、遍历、替换、删除
引言 在Linux平台上工作,我们经常需要使用shell来编写一些有用.有意义的脚本程序.有时,会经常使用shell数组.那么,shell中的数组是怎么表现的呢,又是怎么定义的呢?接下来逐一的进行讲解 ...
- Laravel [1045] Access denied for user 'homestead'@'localhost' .env没有配置
laravel 连接数据库出现错误 PDOException in Connector.php line 55:SQLSTATE[HY000] [1045] Access denied for use ...
- php文件加密(screw方式)
1.上传已经生成好的执行文件. 2.上传扩展文件到目录: /usr/lib64/php/modules 3.上传配置文件到目录: /etc/php.d 4.执行 ./screw a.php 生成加密后 ...
- solidity 错误
solidity版本 0.7.5 Member "transfer" not found or not visible after argument-dependent looku ...
- 鸿蒙内核源码分析(Shell编辑篇) | 两个任务,三个阶段 | 百篇博客分析OpenHarmony源码 | v71.01
子曰:"我非生而知之者,好古,敏以求之者也." <论语>:述而篇 百篇博客系列篇.本篇为: v71.xx 鸿蒙内核源码分析(Shell编辑篇) | 两个任务,三个阶段 ...
- P3308-[SDOI2014]LIS【最小割】
正题 题目链接:https://www.luogu.com.cn/problem/P3308 题目大意 三个\(n\)个数字的序列\(A,B,C\).要求删除其中某些位置\(i\)使得\(A\)的最长 ...
- 【C++ Primer Plus】编程练习答案——第6章
1 void ch6_1() { 2 using namespace std; 3 char ch; 4 while ((ch = cin.get()) != '@') { 5 if (isdigit ...