HDU - 6641 TDL(数学)
You are given the value of m and (f(n,m)−n)⊕n, where ``⊕'' denotes the bitwise XOR operation. Please write a program to find the smallest positive integer n that (f(n,m)−n)⊕n=k, or determine it is impossible.
In each test case, there are two integers k,m(1≤k≤1018,1≤m≤100).
题解:
/// /// _ooOoo_ /// o8888888o /// 88" . "88 /// (| -_- |) /// O\ = /O /// ____/`---'\____ /// .' \\| |// `. /// / \\||| : |||// \ /// / _||||| -:- |||||- \ /// | | \\\ - /// | | /// | \_| ''\---/'' | | /// \ .-\__ `-` ___/-. / /// ___`. .' /--.--\ `. . __ /// ."" '< `.___\_<|>_/___.' >'"". /// | | : `- \`.;`\ _ /`;.`/ - ` : | | /// \ \ `-. \_ __\ /__ _/ .-` / / /// ======`-.____`-.___\_____/___.-`____.-'====== /// `=---=' /// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /// Buddha Bless, No Bug ! /// #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <cstdlib> #include <queue> #include <stack> #include <vector> using namespace std; #define MAXN 100010 #define ll long longint t, m; ll k, ans_n;ll cal(ll n, int m) {if(n < 1)return 0;for(ll i = n + 1; ; i++)if(__gcd(n, i) == 1){m--;if(m == 0)return i - n;/// (i - n) = (f(n, m) - n) = d } }int main() {scanf("%d", &t);while(t--){scanf("%lld%d", &k, &m);ans_n = -1;for(int d = 1; d <= 1000; d++){if(cal(k ^ d, m) == d){if(ans_n == -1)ans_n = k ^ d;else if(ans_n > (d ^ k))/// ^ 运算的有优先度小于 < > == !=ans_n = k ^ d;}}printf("%lld\n", ans_n);}return 0; }
转载于:https://www.cnblogs.com/RootVount/p/11358647.html
HDU - 6641 TDL(数学)相关推荐
- HDU 6641 TDL 异或性质
定义 f ( n , m ) f(n,m) f(n,m)为比 n n n大的第 m m m个与 n n n互质的数,给出 ( f ( n , m ) − n ) ⊕ n (f(n,m)-n)\oplu ...
- 杭电多校 HDU 6641 TDL
题意:给出一个公式 和公式上的m,k试着求是否有n可以符合上面的公式,若有这输出,没有这输出-1 思路: 1.对于f(n,m)因为与n互质的数很大所以求f(n,m)的时间复杂度并不是很高 2.对于给出 ...
- HDUOJ 6641 TDL
HDUOJ 6641 TDL Problem Description For a positive integer n, let's denote function f(n,m) as the m-t ...
- HDU 5914 Triangle 数学找规律
Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, who ...
- Hdu 5339 Untitled (数学思维)
题意:给一个数a和n个数b1,b2,...,bn. 从n个数中选择一些数重新排列成c1,c2,...,cm使得a%c1%c2%...%cm=0. 如果能选出则输出最少需要几个数,否则输出-1. 分析: ...
- HDU 5976 Detachment(数学+结论)
原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=5976 参考博客:https://blog.csdn.net/qq_34374664/article/d ...
- hdu 1593(数学)
转载标记处:http://www.xuebuyuan.com/2131627.html 往相反的方面跑,但是,最理想的初始位置并不是圆点和圆上的某一点,应该还有更理想的初始逃跑状态.这里有一点需要注意 ...
- Circle HDU - 6550 (数学)
在半径为 1 的圆上有 n 个点,它们也是圆的 n 等分点,将每个相邻的 n 等分点相连,组成了一个正 n边形,现在你可以在圆上再增加一个点,使得新的 n + 1 边形的面积最大,请输出最大面积. I ...
- Function HDU - 6546 (数学,贪心)
wls 有 n 个二次函数 Fi(x) = aix2 + bix + ci (1 ≤ i ≤ n). 现在他想在∑ni=1xi = m 且 x 为正整数的条件下求∑ni=1Fi(xi)的最小值. 请求 ...
最新文章
- ZendStudio导入一个已有的网站
- Request_继承体系
- 验证dropdownlist必选
- 利用SOS扩展库进入高阶.NET6程序的调试
- 切题 (problem)(线段树+最大流最小割)
- React开发(202):react代码分割之import导入导出
- eventfd以及epoll原理分析
- LeetCode 2169. 得到 0 的操作数
- 修改端口_如何修改服务器的远程端口
- unity mysql增删改查,XML的使用,增删改查(Unity中的)
- unique函数_包含虚函数的类应该有虚析构函数或保护析构函数?
- CF914D Bash and a Tough Math Puzzle
- 程序员必备神器(FastStoneCapture)
- Swift_学习笔记_调用ObjectiveC方法
- 如何在 WordPress 中启用WebP 图片?webp有什么优势?
- CorelDRAW2023安装下载教程精简版矢量绘图软件
- 玩转“抖音”的10种内容策划套路!
- 无监督学习-案例分析:利率期限结构
- 量子计算磁共振原型机被激光脉冲原型机淘汰
- GDB调试指南-启动调试