摘要:
题目大意:求解n的阶乘末尾0的个数。分析:产生0的原因有:(1):2 * 5(2):乘数末尾有0,如10, 200不过(2)可以归到(1)中,10 = 2 * 5, 200 = 2 * 2 * 2 * 5 * 5容易想到将n!分解成质数的乘积以后,只有2 * 5这种组合可以产生末尾的0,且2的个数一... 阅读全文
摘要:
很简单的优先队列或者堆的使用。 1 #include 2 #include 3 using namespace std; 4 5 //greater对int来说表示值越小优先级越高,也可以自己定义比较函数 6 priority_queue, greater > q; 7 char op[2];... 阅读全文
摘要:
两个栈来模拟浏览器的操作。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 stack forward; 7 stack back; 8 9 int main ()10 {11 string cur("http... 阅读全文
摘要:
其实就是模拟一下栈啦。hdu 1022: 1 #include 2 using namespace std; 3 4 const int N = 10; 5 char o1[N]; 6 char o2[N]; 7 char s[N]; 8 int ans[N * 2]; 9 10 int mai... 阅读全文
摘要:
题目描述:两个人玩游戏取石子,规定取走最后一个石子的人输,取子规则是:如果当前剩余n个石子,则这一步只能取走x个石子,满足n % x = 0. 分析:打了个表发现规律很简单,不过不会证明啊! 阅读全文
摘要:
简单题。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 9; 7 char num[N]; 8 9 int standard( char ch )10 {11 if ( isdig... 阅读全文
摘要:
4088:题意:判断闭区间a到b之间内的素数个数是否为素数。思路:筛吧。 1 #include 2 #include 3 using namespace std; 4 5 const int N = 10001; 6 bool prime[N]; 7 int cnt[N]; 8 9 void... 阅读全文