Problem 2125 简单的等式 Time Limit: 1000 mSec Memory Limit : 32768 KB  Problem Description 现在有一个等式如下:x^2+s(x,m)x-n=0.其中s(x,m)表示把x写成m进制时,每个位数相加的和.现在,在给定n,m的情况下,求出满足等式的最小的正整数x.如果不存在,请输出-1.  Input 有T组测试数据.以下有T(T<=100)行,每行代表一组测试数据.每个测试数据有n(1<=n<=10^18),m(…
思路: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…
Problem Description 现在有一个等式如下:x^2+s(x,m)x-n=0.其中s(x,m)表示把x写成m进制时,每个位数相加的和.现在,在给定n,m的情况下,求出满足等式的最小的正整数x.如果不存在,请输出-1.  Input 有T组测试数据.以下有T(T<=100)行,每行代表一组测试数据.每个测试数据有n(1<=n<=10^18),m(2<=m<=16).  Output 输出T行,有1个数字,满足等式的最小的正整数x.如果不存在,请输出-1.  Sam…
现在有一个等式如下:x^2+s(x,m)x-n=0.其中s(x,m)表示把x写成m进制时,每个位数相加的和.现在,在给定n,m的情况下,求出满足等式的最小的正整数x.如果不存在,请输出-1. Input 有T组测试数据.以下有T(T<=100)行,每行代表一组测试数据.每个测试数据有n(1<=n<=10^18),m(2<=m<=16). Output 输出T行,有1个数字,满足等式的最小的正整数x.如果不存在,请输出-1. Sample Input 4 4 10 110 10…
Description 题目描述 You are given an polynomial of x consisting of only addition marks, multiplication marks, brackets, single digit numbers, and of course the letter x. For example, a valid polynomial would be: (1+x)*(1+x*x+x+5)+1*x*x. You are required…
Description 题目描述 Recently, you have found your interest in string theory. Here is an interesting question about strings. You are given a string S of length n consisting of the first k lowercase letters. You are required to find two non-empty substrin…
题意:固定起点是0,给出一个序列表示n个点,所有点都在一条直线上,其中每个元素代表了从起点到这个点所走的距离.已知路过某个点不算到达这个点,则从起点出发,到达所有点的方案有许多种.求所有方案走的总路程/方案数,输出分子.分母,要求不含约数. e.g:n=3 {2,3,5},{2,3,5}{2,5,3}{3,2,5}{3,5,2}{5,2,3}{5,3,2},总路程(5+7+7+8+9+8)=44,答案44/6=22/3,输出“22 3”. 分析: 1.以n=3序列{a1,a2,a3}为例,实际上…
链接:http://poj.org/problem?id=1298&lang=default&change=true 简单的入门题目也有这么强悍的技巧啊!! 书上面的代码: 很厉害有没有=_= n;main(k){,&n,);k-=n<)k%||putchar(n%<?n:n%%+);} 72字节. 用到了read这个函数 对于不需要处理的字符串,没有作处理,简化了很多.…
Problem Description 如今有一个等式例如以下:x^2+s(x,m)x-n=0. 当中s(x,m)表示把x写成m进制时,每一个位数相加的和.如今,在给定n,m的情况下,求出满足等式的最小的正整数x.假设不存在,请输出-1.  Input 有T组測试数据. 下面有T(T<=100)行,每行代表一组測试数据.每一个測试数据有n(1<=n<=10^18),m(2<=m<=16).  Output 输出T行,有1个数字.满足等式的最小的正整数x.假设不存在,请输出-1…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4627 题目大意:给定一个整数n(2 <= n <= 109),满足a+b=n并且[a,b]的最小公倍数最大. 分析:相当简单的的一道题,因为生病好久没做题目,杭电居然是要用__int64,用long long反而错误,为此,WA了无数遍 代码如下: # include<iostream> # include<cstdio> # include<cmath> us…
题目链接:http://codeforces.com/contest/1096/problem/D 题目大意:给你一个字符串,然后再给你去掉每个字符串的每个字符的花费,然后问你使得字符中不再存在hard这个单词,可以是不连续的. 具体思路:我们从头开始,非hard的单词就不需要考虑了,然后考虑一下,当遇到a的时候,我们就考虑构成h的最小花费,当遇到har的时候,我们就考虑构成ha的最小花费,当遇到hard的时候,我们就考虑构成hard的最小花费就可以了. AC代码: #include <bits…
Easy Problem 时间限制:1000 ms  |  内存限制:65536 KB 描写叙述 In this problem, you're to calculate the distance between a point P(xp, yp, zp) and a segment (x1, y1, z1) ? (x2, y2, z2), in a 3D space, i.e. the minimal distance from P to any point Q(xq, yq, zq) on…
Description Have you heard the fact "The base of every normal number system is 10" ? Of course, I am not talking about number systems like Stern Brockot Number System. This problem has nothing to do with this fact but may have some similarity. Y…
Problem Description Given a sequence 1,2,3,......N, your job is to calculate all the possible sub-sequences that the sum of the sub-sequence is M.   Input Input contains multiple test cases. each case contains two integers N, M( 1 <= N, M <= 1000000…
http://acm.hdu.edu.cn/showproblem.php?pid=5055 题目大意: 给你N位数,每位数是0~9之间.你把这N位数构成一个整数. 要求: 1.必须是奇数 2.整数的前面没有0 3.找到一个最大的整数 如果满足1.2.3条件,就输出这个数,不满足就输出-1. 给个例子 3 1 0 0 这个构成的奇数是001,这个数前面有0,应该输出-1 解题思路: 对给的N个数升序排序. 然后最小的开始找,找到一个奇数,然后把它放在最左边. 然后判断这个数是否,满足要求.满足要…
题目想到了就是一个水题. 提示一下,S(x,m)是一个很小的数.(不超过100) 这样直接枚举这个数,然后求方程的整数解,并且判断是否满足条件即可. ——————(一开始还用Pollard大整数分解+dfs的方法做,,深坑啊) #include <iostream> #include <cstring> #include <cstdio> #include <cmath> #define ll long long using namespace std; l…
*本文主要记录和分享学习到的知识,算不上原创 *参考文献见链接 目录 BL和BLF算法 BF算法 HR算法 PH算法…
You are given an array aa consisting of nn integers. Your task is to determine if aa has some subsequence of length at least 33 that is a palindrome. Recall that an array bb is called a subsequence of the array aa if bb can be obtained by removing so…
给N个数字(0-9),让你组成一个数. 要求:1.这个数是奇数 2.这个数没有前导0 问这个数最大是多少. 思路&解法: N个数字从大到小排序,将最小的奇数与最后一位交换,把剩下前N-1位从大到小排序.输出.(判断第一位是否为0) 代码: #include <cstdio> #include <iostream> #include <string.h> #include <cstdlib> #include <algorithm> #in…
Problem A:简单的图形覆盖 Time Limit:1000MS  Memory Limit:65536KTotal Submit:201 Accepted:104 Description 有一个2*n的方格,要用若干个1*2的模块覆盖,模块可以横放,也可以竖放.问对于给定的n(n<=100),有多少种不同的覆盖方法. Input 有多个测试用例,每个用例占一行,为一个正整数n Output 对于每个测试用例,输出一行相应的结果 Sample Input 9 11 Sample Outpu…
Description 给出两个n位10进制整数x和y,你需要计算x*y. Input 第一行一个正整数n. 第二行描述一个位数为n的正整数x. 第三行描述一个位数为n的正整数y. Output 输出一行,即x*y的结果.(注意判断前导0) Sample Input 134 Sample Output 12 HINT n<=60000 题解 A*B Problem.和 A+B Problem 一样简单. input() and print(int(input()) * int(input()))…
2125: A + B 普拉斯 时间限制: 1 Sec  内存限制: 128 MB 提交: 94  解决: 28 [提交] [状态] [讨论版] [命题人:admin] 题目描述 "别人总说我瓜,其实我一点也不瓜,大多数时候我都机智的一批 机智如宝儿姐,在处理大数加法时也需要借助计算器. 在计算机中,数字是通过像01像素矩阵来显示的,最终的显示效果如下:   现在我们用01来构成这些数字 当宝儿姐输入A + B 时(log10(A)<50,log10(B)<50,且A,B均为正整数)…
目录 List 前言 长郡 Position: code 1. 2. 持续更新,么么哒 List 前言 有没有觉得写这篇文章很奇怪,这个还是有原因的.①很多OJ都有着道题,所以发个博客②这可以介绍很多OJ(持续更新) 长郡 热烈推荐:http://oj.changjun.com.cn/ 然后有一套A+B的神题-Contest4 - A+B Series(http://www.cnblogs.com/YJinpeng/p/5942724.html) Position: POJ-PKU JudgeO…
AbOr's story Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on FZU. Original ID: 198064-bit integer IO format: %I64d      Java class name: Main   As we all known, AbOr has a lots of girls in a palace called “Hou” (About 30 milli…
Twinkling lights III Time Limit: 8000ms Memory Limit: 131072KB This problem will be judged on FZU. Original ID: 196864-bit integer IO format: %I64d      Java class name: Main Twinkling lights一直以来都很好玩的游戏.或许你还记得FZU1069 Twinkling lights 和FZU1420 Twinkli…
QS Network Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on FZU. Original ID: 1096 64-bit integer IO format: %I64d      Java class name: Main   In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS…
Huge Mission Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on FZU. Original ID: 160864-bit integer IO format: %I64d      Java class name: Main Oaiei is busy working with his graduation design recently. If he can not complete it…
栀子花开 Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on FZU. Original ID: 192164-bit integer IO format: %I64d      Java class name: Main 这是一个栀子花开的季节,也是一个离别的季节,四年一千多个日日夜夜,那校园的角角落落,留下了我们沉思的身影:那上百次的成绩排名表,印证了我们深深浅浅不断进步的轨迹,但是这些进步都离不开老…
新击鼓传花游戏 Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on FZU. Original ID: 196264-bit integer IO format: %I64d      Java class name: Main N个小朋友,编号为1..N,玩新击鼓传花游戏.游戏由老师来主持,老师将下达M条命令,命令包含以下三种, L k,让将当前游戏中剩余的小朋友中,编号第k小的小朋友离开游戏. R x…
Problem 2232 炉石传说 不知道fzu的账号在哪里弄,想要做题的可以到vj上面去做 https://vjudge.net/problem/FZU-2232 #include <iostream> #include <cstdio> #include <vector> #include <queue> #include <cstring> using namespace std; , inf = 0x3f3f3f; struct Edge…