摘要:
思路1:暴力枚举即可,数据范围足够小。 1 #include 2 using namespace std; 3 4 int solve( int n, int m ) 5 { 6 int ans = 0; 7 for ( int i = 1; i > t;21 while... 阅读全文
摘要:
题目描述:两个数a和b(a 2 #include 3 #include 4 using namespace std; 5 6 const int N = 1001; 7 const int M = 500001; 8 const int E = 100000; 9 bool p... 阅读全文
摘要:
polya定理的入门题 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int pow( int a, int n ) 7 { 8 int r = 1; 9 while ( n-- )10 {11 r... 阅读全文
摘要:
2561: 1 #include 2 #include 3 using namespace std; 4 5 const int N = 10; 6 int num[N]; 7 8 int main() 9 {10 int t;11 cin >> t;12 while... 阅读全文
摘要:
题目大意:每个数字都可以表示为一些素数的和,原因很显然:由算数基本定理可知,每一个数都可以表示为素数的乘积,自然也就可以表示为一些素数的和咯。于是题目让我们求在这样的表示中出现的最大的素数是第几个素数。思路:一开始想都没想,上了一个这样的代码。 1 #include 2 #include 3 #... 阅读全文
摘要:
基础dfs,输出要求还真是多,可以用stl做,不过自己还是手写了一下。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 4; 7 const int M = 24; 8 con... 阅读全文
摘要:
正则表达式使用单个字符串来描述、匹配一系列符合某个句法规则的字符串。在很多文本编辑器里,正则表达式通常被用来检索、替换那些符合某个模式的文本。许多编程语言都支持正则表达式,C#也不例外,下面让我们来初探正则表达式。首先是元字符,即在正则表达式中具有特殊意义的一些专用字符,可以用一个或一组元字符来代替... 阅读全文
摘要:
两道题基本一样。判断两个数是否互质即可。设x为走的步数,m为间距,则需要判断 x * m % n 是否可以充满0到n - 1的闭区间。互质的话,存在逆元,所以一定可以。hdu 1222: 1 #include 2 using namespace std; 3 4 int gcd( int a, ... 阅读全文
摘要:
骑士巡游找最短路。单向bfs: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 8; 7 const int M = N * N; 8 int step[N][N]; 9 int dir[N]... 阅读全文
摘要:
题目大意:FJ要去抓牛...思路:bfs即可 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 100001; 7 bool visit[N]; 8 9 struct Node10 {11 ... 阅读全文