2020-01-30

分治法

1.什么情况下开始向整体合并
2.切分,递归
3.不同情形的合并方式
#include
using namespace std;
int fz(int n)
{/* if(n0) return 1;*/
if(n
1) return 3;
int m=n/2; int a=fz(m);
if(n%2==0) { return aa%19; }
else { return 3
a*a%19; }
}
int main(){
int x,c=0;
do{ cin>>x; cout<<fz(x); c++; }while(c<3);
}
//while循环纯属无聊,参考老师给的代码,我注释掉的if我认为他想错了,切分的思路如下图。
2020-01-30