日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

HDU - 6641 TDL(数学)

發布時間:2024/4/15 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HDU - 6641 TDL(数学) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Problem Description For a positive integer n, let's denote function f(n,m) as the m-th smallest integer x that x>n and gcd(x,n)=1. For example, f(5,1)=6 and f(5,5)=11.

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.

?

Input The first line of the input contains an integer T(1T10), denoting the number of test cases.

In each test case, there are two integers k,m(1k1018,1m100).

?

Output For each test case, print a single line containing an integer, denoting the smallest n. If there is no solution, output ``-1'' instead.

?

Sample Input 2 3 5 6 100

?

Sample Output 5 -1

?

Source 2019 Multi-University Training Contest 6

題解:

/// /// _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(数学)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。