CodeForces 609B The Best Gift】的更多相关文章

统计+枚举 #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespace std; ]; int main() { int n,m; scanf("%d%d",&n,&m); memset(a,,sizeof a); ;i<=n;i++) { int x; scanf("%d",&…
Codeforces 912 E 题意:给\(n\leq16\)个素数\(p_1..p_n\),求第\(k\)个所有质因数都在\(n\)个数中的数. 思路:折半搜索...我原来胡搞毛搞怎么也搞不动\(16\)的点...直到我突然想到了分成两个\(8\)来搞... 首先我们发现\(n\leq8\)的我们二分+搜索就可以很简单地解决,那么我们据此来搞搞\(n\leq16\)的点. 我们将这些素数分成\(p_1..p_{\lfloor n/2\rfloor}\).\(p_{\lfloor n/2\rf…
题目链接:Prime Gift 题意: 给出了n(1<=n<=16)个互不相同的质数pi(2<=pi<=100),现在要求第k大个约数全在所给质数集的数.(保证这个数不超过1e18) 题解: 如果暴力dfs的话肯定超时间,其实给的n数据范围最大是16是一个很奇妙的数(一般折半枚举基本上是这样的数据范围@.@-).所以想到折半枚举,把所有的质数分成两份求出每份中所有小于1e18的满足条件的数.然后二分答案,写cheak函数时遍历第一个集合,对第二个集合二分(折半枚举基本上这个套路).…
#include<bits/stdc++.h> using namespace std; ]; int main() { memset(num,,sizeof(num)); int n,m,x; cin >> n >> m; ;i<n;i++) { cin >> x; num[x]++; //统计每一个数字出现的次数 } ; ;i<;i++) ;j<=;j++) sum+=num[i]*num[j]; //然后组合 cout <<…
B. The Best Gift 题目连接: http://www.codeforces.com/contest/609/problem/B Description Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale…
The kingdom of Olympia consists of N cities and M bidirectional roads. Each road connects exactly two cities and two cities can be connected with more than one road. Also it possible that some roads connect city with itself making a loop. All roads a…
题目传送门 /* 水题:vector容器实现插入操作,暴力进行判断是否为回文串 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <vector> using namespace std; ; const int INF = 0x3f3f3f3f; vector<c…
题目描述: Prime Gift time limit per test 3.5 seconds memory limit per test 256 megabytes input standard input output standard output Opposite to Grisha's nice behavior, Oleg, though he has an entire year at his disposal, didn't manage to learn how to sol…
题目链接:http://codeforces.com/problemset/problem/505/A 题目意思:给出一个长度不大于10的小写英文字符串 s,问是否能通过在字符串的某个位置插入一个字母,使得新得到的字符串成为回文串. /**************************************(又到自我反省时刻) 做的时候,通过添加一个单位使得长度增加1,找出中点,检验前一半的位置,找出对称位置替换成对应的前一半位置的字符,然后原字符串剩下的部分追加到后面,再判断回文.但是由于…
B. The Best Gift time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the loc…