黑色风格网站主页面,网站设计和备案,wordpress旅游插件,营销手机网站版面由于最近这三天的数学建模#xff0c;让我这个精力本来就不多的AI手更加力竭了#xff0c;没注意到昨晚的cf#xff0c;所以今天来补题了。 比赛连接#xff1a;比赛传送门
A题#xff1a;
You are doing a research paper on the famous Collatz Conjecture. In your e…由于最近这三天的数学建模让我这个精力本来就不多的AI手更加力竭了没注意到昨晚的cf所以今天来补题了。 比赛连接比赛传送门
A题
You are doing a research paper on the famous Collatz Conjecture. In your experiment, you start off with an integer xxx, and you do the following procedure kkk times:
If xxx is even, divide xxx by 222.Otherwise, set xxx to 3⋅x13\cdot x13⋅x1.
For example, starting off with 212121 and doing the procedure 555 times, you get 21→64→32→16→8→421\rightarrow64\rightarrow32\rightarrow16\rightarrow8\rightarrow421→64→32→16→8→4.
After all kkk iterations, you are left with the final value of xxx. Unfortunately, you forgot the initial value. Please output any possible initial value of xxx. Input
Each test contains multiple test cases. The first line contains the number of test cases ttt (1≤t≤4001 \le t \le 4001≤t≤400). The description of the test cases follows.
The first line of each test case contains two integers kkk and xxx (1≤k,x≤201 \leq k,x \leq 201≤k,x≤20). Output
For each test case, print any possible initial value on a new line. It can be shown that the answer always exists. Note
In the first test case, since 111 is odd, performing the procedure k1k1k1 times results in 1⋅3141\cdot3141⋅314, so 111 is a valid output.
In the second test case, since 101010 is even, performing the procedure k1k1k1 times results in 1025\frac{10}{2}52105, so 101010 is a valid output.
The third test case is explained in the statement. 通过观察不难发现两种操作都是变为了偶数所以一直在原来的基础上乘2即可永远都只用操作一即可。 // Problem: A. Collatz Conjecture
// Contest: Codeforces - Codeforces Round 1047 (Div. 3)
// URL: https://codeforces.com/contest/2137/problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)#include bits/stdc.h
using namespace std;
#define int long long
#define endl \n
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pii pairint,int
#define fi first
#define se second
#define YES coutYESendl;
#define NO coutNOendl;
#define lbt(x) ((x) (-x)) const int INF 0x3f3f3f3f;
const int inf 1e18; void solve()
{int n,k;cinkn;int an n;for(int i1;ik;i) an * 2LL;coutanendl;
// coutfixedsetprecision(x) ;
}signed main()// Dont forget pre_handle!
{IOSint T1;cinT;while(T--) solve(); return 0;
}
B题
You are given a permutation∗^{\text{∗}}∗ ppp of size nnn.
Your task is to find a permutation qqq of size nnn such that GCD\operatorname{GCD}GCD†^{\text{†}}†(piqi,pi1qi1)≥3(p_iq_i, p_{i1}q_{i1}) \geq 3(piqi,pi1qi1)≥3 for all KaTeX parse error: Expected EOF, got at position 9: 1 \leq i̲lt;n. In other words, the greatest common divisor of the sum of any two adjacent positions should be at least 333.
It can be shown that this is always possible.
∗^{\text{∗}}∗A permutation of length mmm is an array consisting of mmm distinct integers from 111 to mmm in arbitrary order. For example, [2,3,1,5,4][2,3,1,5,4][2,3,1,5,4] is a permutation, but [1,2,2][1,2,2][1,2,2] is not a permutation (222 appears twice in the array), and [1,3,4][1,3,4][1,3,4] is also not a permutation (m3m3m3 but there is 444 in the array).
†^{\text{†}}†gcd(x,y)\gcd(x, y)gcd(x,y) denotes the greatest common divisor (GCD) of integers xxx and yyy. Input
Each test contains multiple test cases. The first line contains the number of test cases ttt (1≤t≤1041 \le t \le 10^41≤t≤104). The description of the test cases follows.
The first line of each test case contains an integer nnn (2≤n≤2⋅1052 \leq n \leq 2\cdot 10^52≤n≤2⋅105).
The second line contains nnn integers p1,p2,…,pnp_1,p_2,\ldots,p_np1,p2,…,pn (1≤pi≤n1 \leq p_i \leq n1≤pi≤n).
It is guaranteed that the given array forms a permutation.
It is guaranteed that the sum of nnn over all test cases does not exceed 2⋅1052\cdot 10^52⋅105. Output
For each test case, output the permutation qqq on a new line. If there are multiple possible answers, you may output any. Note
In the first test case, GCD(12,33)3≥3\operatorname{GCD}(12,33)3\geq 3GCD(12,33)3≥3 and GCD(33,21)3≥3\operatorname{GCD}(33,21)3\geq3GCD(33,21)3≥3, so the output is correct. 这道题也很好想最大公约数又因为是排列所以我们肯定不难想到用最大的和去和每个元素进行配对这样所有的两个位置上两个排列中所对应的数相加的和都相同了那么这个时候就是满足条件的排列了。 // Problem: B. Fun Permutation
// Contest: Codeforces - Codeforces Round 1047 (Div. 3)
// URL: https://codeforces.com/contest/2137/problem/B
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)#include bits/stdc.h
using namespace std;
#define int long long
#define endl \n
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pii pairint,int
#define fi first
#define se second
#define YES coutYESendl;
#define NO coutNOendl;
#define lbt(x) ((x) (-x)) const int INF 0x3f3f3f3f;
const int inf 1e18; void solve()
{int n;cinn;vectorint a(n1);for(int i1;in;i) cina[i];int sum n 1;for(int i1;in;i) coutsum - a[i] ;coutendl;
// coutfixedsetprecision(x) ;
}signed main()// Dont forget pre_handle!
{IOSint T1;cinT;while(T--) solve(); return 0;
}
C题
You are given two integers aaa and bbb. You are to perform the following procedure:
First, you choose an integer kkk such that bbb is divisible by kkk. Then, you simultaneously multiply aaa by kkk and divide bbb by kkk.
Find the greatest possible even value of ababab. If it is impossible to make ababab even, output −1-1−1 instead. Input
Each test contains multiple test cases. The first line contains the number of test cases ttt (1≤t≤1041 \le t \le 10^41≤t≤104). The description of the test cases follows.
The first line of each test case contains two integers aaa and bbb (1≤a,b≤a⋅b≤1018)1 \leq a,b \leq a\cdot b \leq 10^{18})1≤a,b≤a⋅b≤1018). Output
For each test case, output the maximum even value of ababab on a new line. Note
In the first test case, it can be shown it is impossible for ababab to be even.
In the second test case, the optimal kkk is 222. The sum is 246246246. 分情况讨论即可 // Problem: C. Maximum Even Sum
// Contest: Codeforces - Codeforces Round 1047 (Div. 3)
// URL: https://codeforces.com/contest/2137/problem/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)#include bits/stdc.h
using namespace std;
#define int long long
#define endl \n
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pii pairint,int
#define fi first
#define se second
#define YES coutYESendl;
#define NO coutNOendl;
#define lbt(x) ((x) (-x)) const int INF 0x3f3f3f3f;
const int inf 1e18; void solve()
{int a,b;cinab;if((a * b) 1) {couta * b 1endl;return ;}int ans -1;if(b 1){coutansendl;return ;}if((a * (b / 2LL) 2LL) 1){coutansendl;return ;}// if(a 1LL)// {couta * (b / 2LL) 2LLendl;return ;// }// if(a % 2 0)// {// couta * b// }
// coutfixedsetprecision(x) ;
}signed main()// Dont forget pre_handle!
{IOSint T1;cinT;while(T--) solve(); return 0;
}
D题
Given an array aaa, let f(x)f(x)f(x) be the number of occurrences of xxx in the array aaa. For example, when a[1,2,3,1,4]a[1,2,3,1,4]a[1,2,3,1,4], then f(1)2f(1)2f(1)2 and f(3)1f(3)1f(3)1.
You have an array bbb of size nnn. Please determine if there is an array aaa of size nnn such that f(ai)bif(a_i)b_if(ai)bi for all 1≤i≤n1 \leq i \leq n1≤i≤n. If there is one, construct it. Input
Each test contains multiple test cases. The first line contains the number of test cases ttt (1≤t≤1041 \le t \le 10^41≤t≤104). The description of the test cases follows.
The first line of each test case contains an integer nnn (1≤n≤2⋅1051 \leq n \leq 2\cdot 10^51≤n≤2⋅105).
The second line contains nnn integers b1,b2,…,bnb_1,b_2,\ldots,b_nb1,b2,…,bn (1≤bi≤n1 \leq b_i \leq n1≤bi≤n).
It is guaranteed that the sum of nnn over all test cases does not exceed 2⋅1052\cdot 10^52⋅105. Output
For each test case, output −1-1−1 if there is no valid array aaa.
Otherwise, print the array aaa of nnn integers on a new line. The elements should satisfy 1≤ai≤n1 \leq a_i \leq n1≤ai≤n. Note
In the first test case, it can be shown that no array matches the requirement.
In the second test case, 444, 555, 666 appear 1,2,31,2,31,2,3 times respectively. Thus, the output array is correct as f(4),f(5),f(5),f(6),f(6),f(6)f(4),f(5),f(5),f(6),f(6),f(6)f(4),f(5),f(5),f(6),f(6),f(6) are 1,2,2,3,3,31,2,2,3,3,31,2,2,3,3,3 respectively. 这道题用map嵌套pair可以省去很多步骤思路也比较清楚 // Problem: D. Replace with Occurrences
// Contest: Codeforces - Codeforces Round 1047 (Div. 3)
// URL: https://codeforces.com/contest/2137/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)#include bits/stdc.h
using namespace std;
#define int long long
#define endl \n
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pii pairint,int
#define fi first
#define se second
#define YES coutYESendl;
#define NO coutNOendl;
#define lbt(x) ((x) (-x)) const int INF 0x3f3f3f3f;
const int inf 1e18; void solve()
{int n;cinn;vectorint a(n1);for(int i1;in;i) cina[i];mapint,pii mp;for(int i1;in;i) mp[a[i]].fi ,mp[a[i]].se 0;int num 0;for(auto i : mp) num i.se.fi;if(num ! n){cout-1endl;return ;}for(auto i : mp){int t1 i.fi,t2 i.se.fi;if(t2 % t1){cout-1endl;return ;}}int index 0LL;mapint,int cnt;mapint,bool v;for(int i1;in;i){if(!v[a[i]]) mp[a[i]].se index;if(cnt[a[i]] a[i]){cnt[a[i]] 0;mp[a[i]].se index;}cnt[a[i]] ;v[a[i]] true;coutmp[a[i]].se ;}// for(int i1;in;i) coutmp[a[i]].se ;coutendl;
// coutfixedsetprecision(x) ;
}signed main()// Dont forget pre_handle!
{IOSint T1;cinT;while(T--) solve(); return 0;
}