这是练习题,没啥难度,留作纪念,记录下来 1 #include 2 using namespace std; 3 int main() 4 { 5 int number; 6 7 for (int i = 0; ; i++) 8 { 9 if (i%3 =...
分类:
其他好文 时间:
2014-07-13 22:40:44
阅读次数:
296
#includeusing namespace std;int main(){ int g,l,t; cin>>t; while(t--){ cin>>g>>l; if(l%g==0)//最大公约数一定是最小公倍数的因子 cout ...
分类:
其他好文 时间:
2014-07-13 21:34:46
阅读次数:
176
字典树查询
#include
#include
#include
using namespace std;
const int maxn = 30;
typedef struct Trie{
int v;
Trie *next[ maxn ];
}Trie;
Trie root;
void CreateTrie( char *str ){
int len = strlen( st...
分类:
其他好文 时间:
2014-07-13 17:17:39
阅读次数:
336
有时,当把c风格的不同字符串去实例化函数模版的同一个模版参数时,在实参演绎的过程中经常会发生
意想不到的事情,那就是编译失败,并报错类型不匹配。
正如下面的例子一样:
#include
using namespace std;
/*
*匹配测试
*/
template
int ref_fun(T & t1,T & t2)
{
return strlen(t1) - strlen(t2);...
分类:
其他好文 时间:
2014-07-13 17:04:42
阅读次数:
208
求1~n内所有数对(x,y),gcd(x,y)=质数,的对数。
思路:用f[n]求出,含n的对数,最后用sum【n】求和。
对于gcd(x,y)=a(设x
他们乘积的f[i*a]值包括i的欧拉函数值。时间复杂度(n*质数个数)
#include
#include
using namespace std;
const int maxx=100010;
int mindiv[maxx+5],p...
分类:
其他好文 时间:
2014-07-13 16:45:50
阅读次数:
177
题意为求出只由0,1组成的并且是所给数倍数的数,
广搜。。
因为首位不能为0,因此必为1;所以搜索的下一层为上一层的10倍和10倍加1;
#include
#include
#include
using namespace std;
__int64 s[9999999];
__int64 r;
void show(int q)
{
int i,j;
s[0]=1;
j=0;
i=0;...
分类:
其他好文 时间:
2014-07-13 16:36:40
阅读次数:
172
多重背包的可行性问题。
题意是说 一块表的价格不超过M。你有一些不同数量,也不同面额的硬币。在1-M中你能组成多少种可能。
傻逼的理解成组成不超过M的最大价值。ORZ。。。认真读题……
时间复杂度 O(M*N)
#include
#include
#include
using namespace std;
int dp[2][100005];
int n,m;
...
分类:
其他好文 时间:
2014-07-13 16:19:39
阅读次数:
172
提交地址:点击打开链接
题意: N(N
分析:涉及集合的查询,合并,取最值。 利用并查集和左偏树即可解决。
#include
#include
#include
#include
using namespace std;
const int maxn = 200000;
int tot, v[maxn], l[maxn], r[maxn], d[maxn], f[...
分类:
其他好文 时间:
2014-07-13 15:38:55
阅读次数:
183
代码:
#include
#include
#include
#include
int main()
{
int num[100];
int odd = 0, even = 0;
std::string str;
getline(std::cin, str);
std::stringstream s(str);
int j = 0;
while(getline(s, s...
分类:
其他好文 时间:
2014-07-13 13:54:31
阅读次数:
280
1 #include 2 #include 3 #include 4 using namespace std; 5 6 void swap(int *a, int *b){ 7 int tmp; 8 tmp = *a; 9 *a = *b;10 *b = tmp;...
分类:
其他好文 时间:
2014-07-13 13:11:27
阅读次数:
190