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 ...
随机推荐
- v-model指令实现简单的问卷表格
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&q ...
- Spring Boot(十五):spring boot+jpa+thymeleaf增删改查示例
Spring Boot(十五):spring boot+jpa+thymeleaf增删改查示例 一.快速上手 1,配置文件 (1)pom包配置 pom包里面添加jpa和thymeleaf的相关包引用 ...
- eclispe设置workspace text file encoding
在windows下开发,经常会遇到eclipse新导入的工程 java代码中的注释或者字符串中文显示乱码,每次都要一个个项目更改麻烦,特地找了下,可通过如下方法一次性设置.
- C# ms speech文字转语音例子
最近突发奇想 想玩玩 文字转语音的东东 谷歌了一下 发现微软有一个TTS 的SDK 查了查相关资料 发现 还真不错 然后就开始玩玩Microsoft Speech SDK的 DEMO了 ...
- Linux和windows之间使用scp无密码传输文件,脚本自动化
1.环境 windows2008 R2 和rhel 6.5 2.需求 通过在windows上指定计划任务,自动完成从Linux系统上备份文件到windows 3.工具 win: SSH Secure ...
- PHP命名空间(Namespace)的使用简介
原文链接:https://www.cnblogs.com/zhouguowei/p/5200878.html 可以导入命名空间也可以导入命名空间的类 <?php namespace Blog\A ...
- 买不到的数目|2018年蓝桥杯A组题解析第八题-fishers
买不到的数目 小明开了一家糖果店.他别出心裁:把水果糖包成4颗一包和7颗一包的两种.糖果不能拆包卖. 小朋友来买糖的时候,他就用这两种包装来组合.当然有些糖果数目是无法组合出来的,比如要买 10 颗糖 ...
- 【注册码】Matlab7.0(R14)注册码
Matlab 7 (R14) 注册码1:14-13299-56369-16360-32789-51027-35530-39910-50517-56079-43171-43696-14148-64597 ...
- P2604 [ZJOI2010]网络扩容
思路 简单的费用流问题,跑出第一问后在残量网络上加边求最小费用即可 代码 #include <cstdio> #include <algorithm> #include < ...
- MongoDB集群配置笔记一
MongoDB 的部署方案有单机部署.复本集(主备)部署.分片部署.复本集与分片混合部署.混合的部署方式如图: 分片集群的构造 (1)mongos :数据路由,和客户端打交道的模块.mongos本身没 ...