- 博客(5)
- 收藏
- 关注
转载 最大连续子序列和
#include #include #define N 10000 using namespace std; int a[N]; int main() { int n,temp,flag,sum,s,e,Max; while(~scanf("%d",&n)&&n!=0) ...
2019-05-27 20:05:22
152
原创 一队蚂蚁在一根水平杆上行走,每只蚂蚁固定速度 1cm/s. 当一只蚂蚁走到杆的尽头时,立即从秆上掉落. 当两只蚂蚁相遇时它们会掉头向相反的方向前进. 我们知道每只蚂蚁在杆上的初始位置, 但是, 我们不
#include<stdio.h> #include #include using namespace std; const int maxn = 1000000+10; int c[maxn]; int main() { int n,a,b,i; int tmin,tmax; scanf("%d",&n); while(n–) { tmin=tmax=0; scanf("%d...
2019-05-07 16:11:12
2080
原创 有排成一行的n个方格,用红(Red)、粉(Pink)、绿(Green)三色涂每个格子,每格涂一色,要求任何相邻的方格不能同色,且首尾两格也不同色.求全部的满足要求的涂法.
可分为两种情况 1.当倒数第二个与第一个同色(最后一个有两种情况)有f[n-2]2 2.不同色是(最后一种只有一种情况)有f[n-1]; #include<stdio.h> int main() { int n,i; long long f[99]; while(scanf("%d",&n)!=EOF) { f[0]=0;f[1]=3;f[2]=6;f[3]=6; for(i=...
2019-05-07 15:35:26
3961
原创 快速幂以及取后三位
#include<stdio.h> int main() { int a,b,x,ans; ans=1; while(b) { if(b%2)//当b为奇数时执行 { ans*=a; //ans%=1000;取后三位; } b/=2; a*=a; //a%=1000; } printf("%d\n",ans); rerurn 0; }
2019-05-07 15:03:31
485
原创 并查集
#include<stdio.h> using namespace std; int i,k,n,m,f[10010],p1,p2,p3; int find(int k){ //路径压缩 if(f[k]k)return k; return f[k]=find(f[k]); } int main() { scanf("%d%d%d",&n,&m); for(i=1;i&l...
2019-04-07 21:39:43
146
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅