Codeforces 934D - A Determined Cleanup
思路:
找规律,和k进制的求法差不多,答案的奇数位是p%k,偶数位如果p%k!=0,那么答案是k-p%k,否则为0。
代码:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a)) const int N=2e3+;
vector<int>ans;
int main(){
ios::sync_with_stdio(false);
cin.tie();
ll p,k;
cin>>p>>k;
int t=;
while(p){
if(t%==)ans.pb(p%k),p/=k;
else{
if(p%k)ans.pb(k-p%k),p=p/k+;
else ans.pb(),p=p/k;
}
t++;
}
cout<<ans.size()<<endl;
for(int i=;i<ans.size();i++)cout<<ans[i]<<' ';
cout<<endl;
return ;
}
Codeforces 934D - A Determined Cleanup的更多相关文章
- [Codeforces 933B]A Determined Cleanup
Description 题库链接 给你两个正整数 \(p,k\) ,询问是否能够构造多项式 \(f(x)=\sum\limits_{i=0}^{d-1}a_ix^i\) ,使得存在多项式 \(q(x) ...
- Codeforces 934.D A Determined Cleanup
D. A Determined Cleanup time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces Round #462 (Div. 2) D. A Determined Cleanup
D. A Determined Cleanup time limit per test1 second memory limit per test256 megabytes Problem Descr ...
- [codeforces934D]A Determined Cleanup
[codeforces934D]A Determined Cleanup 试题描述 In order to put away old things and welcome a fresh new ye ...
- Codeforces 934D/933B - A Determined Cleanup
传送门:http://codeforces.com/contest/934/problem/D 给定两个正整数p(p≥1).k(k>1).多项式f(x)的系数的取值集合为{0,1,2,...,k ...
- Codeforces Round #464 (Div. 2) A Determined Cleanup
A. Love Triangle time limit per test1 second memory limit per test256 megabytes Problem Description ...
- 【Codeforces Round #462 (Div. 1) B】A Determined Cleanup
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 设\(设f(x)=a_d*x^{d}+a_{d-1}*x^{d-1}+...+a_1*x+a_0\) 用它去除x+k 用多项式除法除 ...
- codeforces 462div.2
A A Compatible Pair standard input/output 1 s, 256 MB x1916 B A Prosperous Lot standard input/out ...
- Codeforces水题集合[14/未完待续]
Codeforces Round #371 (Div. 2) A. Meeting of Old Friends |B. Filya and Homework A. Meeting of Old Fr ...
随机推荐
- 静态代码检查findbugs/阿里巴巴开发规范
findbugs,基本上三类严重的bug检测出来都是比较准确的,如下: 阿里巴巴开发规范 前面两类都是比较重要的: 参考: https://blog.csdn.net/qq_27093465/arti ...
- 【题解】Luogu P4391 [BOI2009]Radio Transmission 无线传输
原题传送门 这题需要用到kmp匹配 推导发现: 设循环节的长度为x,那么kmp数组前x个都是0,后面kmp[x+n]=n 先求出kmp数组 答案实际就是len-kmp[len] #include &l ...
- Windows死机的话,可能的一些猫病
一.由硬件引起的原因 [散热不良] 显示器.电源和CPU在工作中发热量非常大,因此保持良好的通风状况非常重要,如果显示器过热将会导致色彩.图象失真甚至缩短显示器寿命.工作时间太长也会导致电源或显示器散 ...
- 利用JQuery Mobile开发web app
什么是web app web app 是基于web的应用程序,是针对移动设备优化后的web站点,它具有 开发成本低——采用web开发技术,不需要考虑跨平台以及底层适配问题: 升级简单——不需要通知用户 ...
- B/S交互过程及tomcat体系结构
浏览器与服务器交互过程: 1.浏览器根据主机名,如www.baidu.com,去操作系统的hosts文件中查找主机名对应的ip地址. 2.如果查找不到,则会去互联网上的dns服务器上查找主机名对应的i ...
- Restful framework【第三篇】序列化组件
基本使用 -序列化 -对象,转成json格式 用drf的序列化组件 -定义一个类继承class BookSerializer(serializers.Serializer): -写字段,如果不指定so ...
- minicom支持向串口自动发送命令的功能
1. 用法 minicom -S <script name> -C <log name> 参数解析: -S: 指定要执行的脚本 -C: 指定输出日志文件名 2. 既然可以指定脚 ...
- tp框架中的一些疑点知识-8
NaN是Number对象的一个属性, 表示一个特殊值, 表示不是一个 数字, 引用/赋值时, 要使用: Number.NaN 判断 一个值是不是 NaN, 用 isNaN() 函数, 它是一个js的全 ...
- Spring-Cache 注解 @Cacheable,@CachePut , @CacheEvict
1.自动生成key @Bean public KeyGenerator keyGenerator() { return new KeyGenerator() { @Override public Ob ...
- 在VMware14上安装centos6.5
打开vmware14 => 创建新虚拟机(即再建一个linux),已有光盘映像文件,正常操作即可.