摘要: 1059 Prime Factors (25分) Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format Input Specifica 阅读全文
posted @ 2020-07-13 14:28 cicinnus 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 1、素数的判断 O(sqrt(n)) bool isprime(int n) { if (n <= 0) return false; int sqr = (int)sqrt(1.0 * n); for (int i = 2; i <= sqr; i++) { if (n % i == 0) retu 阅读全文
posted @ 2020-07-13 09:56 cicinnus 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 1014 Waiting in Line (30分) Suppose a bank has N windows open for service. There is a yellow line in front of the windows which devides the waiting are 阅读全文
posted @ 2020-07-11 20:39 cicinnus 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 问题描述:任意两个皇后都不能处于同一行、同一列或同一斜线上,问有多少种摆法。 如果把n列皇后所在的行号依次写出,会是1-n的一个排列,因此可以考虑用全排列解题,用回溯法优化。 const int maxn = 8; int n, cnt = 0; int hashTable[maxn] = { fa 阅读全文
posted @ 2020-07-03 23:22 cicinnus 阅读(289) 评论(0) 推荐(0) 编辑
摘要: 1、暴力解法 时间O(n^3) 空间O(1) string longestPalindrome(string s) { int len = s.length(); if (len < 2) { return s; } int maxn = 1; int idx = 0; for (int i = 1 阅读全文
posted @ 2020-07-02 22:36 cicinnus 阅读(1624) 评论(0) 推荐(1) 编辑
摘要: 1、面向有连接型和面向无连接型 面向有连接型 在发送数据之前,需要在收发主机之间建立一条通信线路。必须在通信传输前后么专门进行建立和断开链接的处理。如果与对端之间无法通信,就可以避免发送不必要的数据。 在面向有连接型的情况下,发送端的数据不一定要分组发送,电路交换也属于面向有连接的一种方式。 面向无 阅读全文
posted @ 2020-07-01 22:05 cicinnus 阅读(657) 评论(0) 推荐(0) 编辑
摘要: 简单说明OSI模型中各个分层的主要作用: 1、物理层 物理层以“0”,“1”表示电压的高低,灯光的闪灭。界定连接器与网线的规格。 比特流与电子信号之间的切换 确定连接器与网线之间的规格 2、数据链路层 数据链路层负责互联设备之间传送和识别数据帧。 数据帧与比特流之间的转换 分段转发数据 3、网络层 阅读全文
posted @ 2020-07-01 21:24 cicinnus 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 1、将P进制数x a1a2a3...an 转换为十进制数y int y=0,product=1; while(x!=0){ y=y+(x%10)*product; x=x/10; product=product*P; } 2、将十进制数y转换为Q进制数z(do-while是为了防止y=0时while 阅读全文
posted @ 2020-06-30 21:17 cicinnus 阅读(192) 评论(2) 推荐(1) 编辑