思路:x绝对小于根号n,再由s(x,m)可以缩小范围。1e9十六进制大约算出每位和相加100左右。这种题直接判断范围再暴力。

 #include<stdio.h>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iostream>
#define LL long long
using namespace std; int main() {
//freopen("in.txt","r",stdin);
__int64 t,n,m,ans;
scanf("%I64d",&t);
while(t--) {
scanf("%I64d%I64d",&n,&m);
__int64 x = sqrt(n*1.0);
ans = -;
while(x) {
if(n%x==) {
__int64 sum = ,tem = x;
while(tem) {
sum+=tem%m;
tem/=m;
}
if(sum == n/x-x) {
ans = x;
}
}
if(n/x-x>)
break;
x--;
}
printf("%I64d\n",ans);
}
return ;
}

  

FZU Problem 2125 简单的等式的更多相关文章

  1. Problem 2125 简单的等式(FZU),,数学题。。。

    Problem 2125 简单的等式 Time Limit: 1000 mSec Memory Limit : 32768 KB  Problem Description 现在有一个等式如下:x^2+ ...

  2. FZU 2125 简单的等式

    Problem Description 现在有一个等式如下:x^2+s(x,m)x-n=0.其中s(x,m)表示把x写成m进制时,每个位数相加的和.现在,在给定n,m的情况下,求出满足等式的最小的正整 ...

  3. FZU 2125 简单的等式 【数学/枚举解方程式】

    现在有一个等式如下:x^2+s(x,m)x-n=0.其中s(x,m)表示把x写成m进制时,每个位数相加的和.现在,在给定n,m的情况下,求出满足等式的最小的正整数x.如果不存在,请输出-1. Inpu ...

  4. FZu Problem 2233 ~APTX4869 (并查集 + sort)

    题目链接: FZu Problem 2233 ~APTX4869 题目描述: 给一个n*n的矩阵,(i, j)表示第 i 种材料 和 第 j 种材料的影响值,这个矩阵代表这n个物品之间的影响值.当把这 ...

  5. FZu Problem 2236 第十四个目标 (线段树 + dp)

    题目链接: FZu  Problem 2236 第十四个目标 题目描述: 给出一个n个数的序列,问这个序列内严格递增序列有多少个?不要求连续 解题思路: 又遇到了用线段树来优化dp的题目,线段树节点里 ...

  6. 翻翻棋(找规律问题)(FZU Problem 2230)

    题目是这样的: FZU Problem 2230 象棋翻翻棋(暗棋)中双方在4*8的格子中交战,有时候最后会只剩下帅和将.根据暗棋的规则,棋子只能上下左右移动,且相同的级别下,主动移动到地方棋子方将吃 ...

  7. FZU 2215 Simple Polynomial Problem(简单多项式问题)

    Description 题目描述 You are given an polynomial of x consisting of only addition marks, multiplication ...

  8. FZU 2218 Simple String Problem(简单字符串问题)

    Description 题目描述 Recently, you have found your interest in string theory. Here is an interesting que ...

  9. fzu Problem 2128 最长子串(KMP + strstr 经典好题)

     Problem Description 问题很简单,给你一个字符串s,问s的子串中不包含s1,s2...sn的最长串有多长.  Input 输入包含多组数据.第一行为字符串s,字符串s的长度1到10 ...

随机推荐

  1. node.js里的forEach()也是异步的吗?

    博客已经迁移到www.imyzf.com,本站不再更新,请谅解! node里几乎所有用到回调函数的地方,都是异步的,回调函数后面的代码很可能比回调函数中的代码后先执行,特别是数据库操作.当然,node ...

  2. jquery点击其他地方隐藏div层的实现程序

    js代码 $(document).ready(function() { //语言头部的点击事件,显示语言列表 $(".language_selected").click(funct ...

  3. Python3.4 多线程

    线程安全和全局解释器锁 Thread State and the Global Interpreter Lock 总结: 通过使用GIL后, Python多线程安全, 并且数据保持同步. Python ...

  4. python编程语言 函数的形参

    python编程语言 函数的形参的讲解: 我在交互模式中写了个函数: def adder(**args): sum=0 for x in args.keys(): sum+=args[x] retur ...

  5. python使用psutil获取服务器信息

    >>> import psutil 获取cpu信息>>> psutil.cpu_times()scputimes(user=128258.38, nice=12.2 ...

  6. js函数文件排序化

    因为本人的某些小强迫症,写了一个格式化并根据js函数名排序的c++程序,此作mark #include <stdio.h> #include <map> #include &l ...

  7. ColorDialog组件设置字体颜色

    1.设置颜色 private void button4_Click(object sender, EventArgs e) { this.colorDialog1.ShowDialog(); this ...

  8. CATransition的动画效果类型及实现方法--老代码备用参考

    实现iphone漂亮的动画效果主要有两种方法,一种是UIView层面的,一种是使用CATransition进行更低层次的控制, 第一种是UIView,UIView方式可能在低层也是使用CATransi ...

  9. JAVA入门第二季(mooc-笔记)

    相关信息 /** * @subject <学习与创业>作业1 * @author 信管1142班 201411671210 赖俊杰 * @className <JAVA入门第二季&g ...

  10. leetcode-173:Binary Search Tree Iterator(Java)

    Binary Search Tree Iterator Implement an iterator over a binary search tree (BST). Your iterator wil ...