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 ...
随机推荐
- The Architecture of Open Source Applications: Berkeley DB
最近研究内存关系数据库的设计与实现,下面一篇为berkeley db原始两位作为的Berkeley DB设计回忆录: Conway's Law states that a design reflect ...
- gcc对c++标准的支持
GCC 4.8.1完全支持c++11核心部分,对应的glibc为2.17 gcc 4.9支持c++11正则表达式,卧槽...4.8.5会报terminate called after throwing ...
- memory cache 和 disk cache
memory cache简介:MemoryCache顾名思义,就是将资源缓存到内存中,等待下次访问时不需要重新下载资源,而直接从内存中获取.Webkit早已支持memoryCache. 目前Webki ...
- bzoj 1420 Discrete Root - 原根 - exgcd - BSGS
题目传送门 戳我来传送 题目大意 给定$k, p, a$,求$x^{k}\equiv a \pmod{p}$在模$p$意义下的所有根. 考虑模$p$下的某个原根$g$. 那么$x = g^{ind_ ...
- POJ 2387 Til the Cows Come Home 【最短路SPFA】
Til the Cows Come Home Description Bessie is out in the field and wants to get back to the barn to g ...
- 洛谷luogu2782
P2782 友好城市 题目描述 有一条横贯东西的大河,河有笔直的南北两岸,岸上各有位置各不相同的N个城市.北岸的每个城市有且仅有一个友好城市在南岸,而且不同城市的友好城市不相同.每对友好城市都向政府申 ...
- kubeadm 生成的token过期后,集群增加节点
通过kubeadm初始化后,都会提供node加入的token: You should now deploy a pod network to the cluster. Run "kubect ...
- Optical Flow related Tutorials
Optical Flow related Tutorials 2017-04-01 10:50:55 Reference: 1. http://blog.csdn.net/carson2005/art ...
- 【C#】可空类型 NullAble<T>
在实际编写代码时候 , 会遇到很多场景, 需要将值置成空, 比如发货日期, 有可能是没有. 在没有可空类型之前, 程序都是用 魔值, 即为一个minValue或者常量, 来代表这个值为空, 也有用一 ...
- 【JS】js操作json object
//将表单序列化成字符串 $.fn.serializeObject = function () { var obj = {}; var count = 0; $.each(this.serialize ...