Educational Codeforces Round 66 (Rated for Div. 2) A. From Hero to Zero
链接:https://codeforces.com/contest/1175/problem/A
题意:
You are given an integer nn and an integer kk.
In one step you can do one of the following moves:
- decrease nn by 11;
- divide nn by kk if nn is divisible by kk.
For example, if n=27n=27 and k=3k=3 you can do the following steps: 27→26→25→24→8→7→6→2→1→027→26→25→24→8→7→6→2→1→0.
You are asked to calculate the minimum number of steps to reach 00 from nn.
思路:
暴力,模拟。
代码:
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long LL;
- const int MAXN = 3e5 + 10;
- const int MOD = 1e9 + 7;
- LL n, m, k, t;
- int main()
- {
- cin >> t;
- while (t--)
- {
- cin >> n >> m;
- LL res = 0;
- while (n)
- {
- res += n%m;
- if (n >= m)
- res++;
- n = n/m;
- // cout << n << ' ' << res << endl;
- }
- cout << res << endl;
- }
- return 0;
- }
Educational Codeforces Round 66 (Rated for Div. 2) A. From Hero to Zero的更多相关文章
- Educational Codeforces Round 66 (Rated for Div. 2) B. Catch Overflow!
链接:https://codeforces.com/contest/1175/problem/B 题意: You are given a function ff written in some bas ...
- Educational Codeforces Round 66 (Rated for Div. 2) A
A. From Hero to Zero 题目链接:http://codeforces.com/contest/1175/problem/A 题目 ou are given an integer n ...
- Educational Codeforces Round 66 (Rated for Div. 2)
A.直接模拟. #include<cstdio> #include<cstring> #include<iostream> #include<algorith ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...
随机推荐
- .net 常用的插件列表
1,.net 分布式Session 解决方案RedisSessionStateProvider 2,c# 表达式树查看工具 Expression Tree Visualizer 3,sqlbuilde ...
- listen 60
Barbie Exposure May Limit Girls' Career Imagination The ubiquitous Barbie doll: she's been everythin ...
- linux 进程学习笔记-进程退出/终止进程
<!--[if !supportLists]-->Ÿ <!--[endif]-->退出/终止进程 void _exit(int status) 与 void exit(int ...
- P2764 [网络流24题]最小路径覆盖问题[最大流]
地址 这题有个转化,求最少的链覆盖→即求最少联通块. 设联通块个数$x$个,选的边数$y$,点数$n$个 那么有 $y=n-x$ 即 $x=n-y$ 而n是不变的,目标就是在保证每个点入度.出度 ...
- Pycharm用鼠标滚轮控制字体大小的
Pycharm用鼠标滚轮控制字体大小的 一.pycharm字体放大的设置 File —> setting —> Keymap —>在搜寻框中输入:increase —> I ...
- Spring 3.1新特性之三:Spring对声明式缓存的支持
一.概述: Spring 3.1 引入了激动人心的基于注释(annotation)的缓存(cache)技术,它本质上不是一个具体的缓存实现方案(例如EHCache 或者 OSCache),而是一个对缓 ...
- DBS:目录
ylbtech-DBS:目录 1.返回顶部 1. 2. 2.返回顶部 3.返回顶部 4.返回顶部 5.返回顶部 6.返回顶部 7.返回顶部 8.返回顶部 9.返回顶 ...
- DS:template
ylbtech-DS: 1.返回顶部 2.返回顶部 3.返回顶部 4.返回顶部 5.返回顶部 6.返回顶部 作者:ylbtech出处:http://ylbtech.cnbl ...
- Jasper:目录/资源
ylbtech-Jasper:目录/资源 1. 官网返回顶部 1. https://www.jasper.com/ 2. 2.返回顶部 1. http://api.jasperwireless.com ...
- MySql介绍及优化(1)
mysql 数据库 1.是关系型数据库: 2.体积小.支持多处理器.开源.免费 3.在 Internet 中小型网站中的使用率尤其高 mysql 数据库开发常见问题及优化 一.库表设计 1.1 引擎选 ...