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+5;
vector<int>ans;
int main(){ios::sync_with_stdio(false);cin.tie(0);ll p,k;cin>>p>>k;int t=0;while(p){if(t%2==0)ans.pb(p%k),p/=k;else{if(p%k)ans.pb(k-p%k),p=p/k+1;else ans.pb(0),p=p/k;}t++;}cout<<ans.size()<<endl;for(int i=0;i<ans.size();i++)cout<<ans[i]<<' ';cout<<endl;return 0;
} 

转载于:https://www.cnblogs.com/widsom/p/8449499.html

Codeforces 934D - A Determined Cleanup相关推荐

  1. Codeforces Round #462 (Div. 2)题解

    Codeforces Round #462 (Div. 2) B题--我固执的认为1e18是18位数,导致被hack,花了20分钟才检查出这个错误,很僵硬 Codeforces 934C 题意 给定一 ...

  2. Codeforces Gym 100513G G. FacePalm Accounting 暴力

    G. FacePalm Accounting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513 ...

  3. Codeforces Round #331 (Div. 2) A. Wilbur and Swimming Pool 水题

    A. Wilbur and Swimming Pool Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...

  4. Codeforces Round #299 (Div. 2) D. Tavas and Malekas kmp

    题目链接: http://codeforces.com/problemset/problem/535/D D. Tavas and Malekas time limit per test2 secon ...

  5. Codeforces Round #597 (Div. 2) - BenFromHRBUST

    Codeforces Round #597 (Div. 2) -----比赛传送门----- A - Good ol' Numbers Coloring Problem Description Con ...

  6. Codeforces Round #335 (Div. 2) D. Lazy Student 构造

    D. Lazy Student Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/606/probl ...

  7. Codeforces Beta Round #2-A. Winner——算法笔记

    题目链接:http://codeforces.com/problemset/problem/2/A 题目描述: The winner of the card game popular in Berla ...

  8. CodeForces 375D Tree and Queries

    传送门:https://codeforces.com/problemset/problem/375/D 题意: 给你一颗有根树,树上每个节点都有其对应的颜色,有m次询问,每次问你以点v为父节点的子树内 ...

  9. 「日常训练」Bad Luck Island(Codeforces Round 301 Div.2 D)

    题意与分析(CodeForces 540D) 是一道概率dp题. 不过我没把它当dp做... 我就是凭着概率的直觉写的,还好这题不算难. 这题的重点在于考虑概率:他们喜相逢的概率是多少?考虑超几何分布 ...

  10. 【codeforces 812C】Sagheer and Nubian Market

    [题目链接]:http://codeforces.com/contest/812/problem/C [题意] 给你n个物品; 你可以选购k个物品;则 每个物品有一个基础价值; 然后还有一个附加价值; ...

最新文章

  1. java类接口的区别_【Java基础】java接口和类的区别-瑶瑶吖的回答
  2. 【Spring Web MVC】Spring Web MVC 注解开发环境搭建
  3. sys.stderr.write(f“ERROR: {exc}“) SyntaxError: invalid syntax错误
  4. fatal error C1083: 无法打开包括文件:“stdio.h
  5. [APP]- 找回Xcode7的代码折叠功能
  6. mondrain配置mysql_mondrian 4.7 源码部署(示例代码)
  7. Spring CGLlB动态代理
  8. 【论文笔记】K-plet Recurrent Neural Networks for Sequential Recommendation
  9. 文本导入ORACLE快速,Oracle批量导入文本文件快速的方法(sqlldr实现)
  10. oracle 触发器 实例
  11. 如何使用ESP8266、ESP8285做一个WiFi中继(WiFi信号放大器)
  12. (转载)c++builder/delphi中透明panel及透明窗口的实现方法_delphi教程
  13. 【python】小游戏程序——弹跳小球
  14. linux卸载nvdia驱动_Ubuntu 卸载 Nvidia 驱动和安装最新驱动
  15. 三层交换技术与链路聚合
  16. 台式电脑怎么装win10 win11重装win10系统
  17. Service与Android系统设计(5)-- libbinder
  18. 【JS组件系列】——表格组件神器:bootstrap table(二:父子表和行列调序)
  19. ios合并两张图片(叠加两张图片 重合两张图片)
  20. 服务器低功耗cpu性能,CPU走低功耗 难以解决服务器功耗问题

热门文章

  1. 【文章】《陋室铭》《陋妻铭》《微信铭》《交友铭》《老人铭》
  2. 写给理工科人看的乐理(二)十二平均律与五线谱
  3. 利用手机距离感应器来切换是用扬声器听音乐还是听筒听音乐
  4. 计算机桌面常见故障,电脑桌面的常见问题及解决办法
  5. 超级蓝筹股是什么意思?a股蓝筹股是什么意思?
  6. 蓝筹股是什么意思?低估值蓝筹股有哪些?拥有蓝筹股的好处?
  7. java源文件只能有一import_Java源文件的声明规则
  8. 网络骇客入门之UDP编程
  9. html flv jquery 插件,基于js与flash实现的网站flv视频播放插件代码
  10. Unity发布抖音小游戏:广告ID申请