码迷,mamicode.com
首页 >  
搜索关键字:std    ( 41627个结果
某单位排队形,开始排成3路纵队,末尾多出2个人,后改称5路纵队,末尾又多出3个人 ,后改成7路纵队,正好没有余数,求单位总人数
这是练习题,没啥难度,留作纪念,记录下来 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
uva11388
#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
Trie树
字典树查询 #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
省赛i题/求1~n内所有数对(x,y),满足最大公约数是质数的对数
求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
poj 1426 Find The Multiple
题意为求出只由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
POJ 1742 Coins
多重背包的可行性问题。 题意是说 一块表的价格不超过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
zoj2334 Monkey King , 并查集,可并堆,左偏树
提交地址:点击打开链接 题意:  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
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!