![image-20200718102741944](https://i-blog.csdnimg.cn/blog_migrate/546d7e2cce21b41a4c76594cb68d60db.png)
![image-20200718102833146](https://i-blog.csdnimg.cn/blog_migrate/c90defc6968c733045e250fa1a087f1a.png)
#include <iostream>
using namespace std;
int main()
{
int i,j,k;
for(i=0;i<20;i++)
for(j = 0;j<34;j++)
for(k=0;k<300;k++)
if((15*i+9*j+k)==300 && (i+j+k)==100)
printf("cook=%d,hen=%d,chicken=%d\n",i,j,k);
return 0;
}
![image-20200718102929543](https://i-blog.csdnimg.cn/blog_migrate/745b18e3b9df6bfca7ce9852c94b0fdf.png)
#include <iostream>
using namespace std;
int main()
{
int n;
int i,j;
int sum = 0;
cin >> n;
for(i=2;i<=n;i++)
{
sum = 0;
for(j=1;j<i;j++)
{
if(i%j == 0)
sum += j;
}
if(sum == i)
{
printf("%d its factors are ",i);
for(j=1;j<i;j++)
if(i%j == 0)
cout << j << " ";
cout << endl;
}
}
return 0;
}
![image-20200718103128145](https://i-blog.csdnimg.cn/blog_migrate/04471e1f2cf6324a5e377935fc40ed24.png)
#include <iostream>
#include <math.h>
using namespace std;
int isPrime(int n)
{
double j;
int i;
j = sqrt(n);
for(i=2;i<=j;i++)
if(n%i == 0)
return 0;
return 1;
}
int turn(int n)
{
int a,b,c;
a=n/100;
b=n%100/10;
c=n%10;
return c*100+b*10+a;
}
int main()
{
int i,m,n;
cin >> m >> n;
for(i=m;i<=n;i++)
{
if((i/100)%2==0)
{
i=i+100;
continue;
}
if(isPrime(i)==0)
continue;
else if (isPrime(turn(i))&&i<turn(i))
cout << i << endl;
}
return 0;
}
![image-20200718103202276](https://i-blog.csdnimg.cn/blog_migrate/40383c18276ec8f8350f1866b045832c.png)
#include <iostream>
#include <string.h>
using namespace std;
int getnext(char *t,int *next,int tlength)
{
int i = 1,j = 0;
next[1] = 0;
while(i<tlength)
{
if(j==0||t[i]==t[j])
{
++i;
++j;
next[i]=j;
}
else
{
j = next[j];
}
}
return 0;
}
int indexkmp(char *s,char *t,int pos,int tlength,int slength,int *next)
{
int i = pos,j = 1;
while(i<=slength && j <= tlength){
if(j==0||s[i]==t[j])
{
++i;
++j;
}
else
{
j=next[j];
}
}
if(j>tlength)
return i-tlength;
else
return -1;
}
int main()
{
int locate,tlength,slength,next[256];
char s[256],t[256];
slength = strlen(gets(s+1));
tlength = strlen(gets(t+1));
getnext(t,next,tlength);
locate = indexkmp(s,t,0,tlength,slength,next);
cout << locate << endl;
return 0;
}
![image-20200718103239825](https://i-blog.csdnimg.cn/blog_migrate/a96f20633b27b73343e96ba4c501b0ca.png)
#include <iostream>
using namespace std;
int max(int x,int y,int z)
{
if(x>y&&x>z) return x;
else if(y>x&&y>z) return y;
else return z;
}
int main()
{
int x1,x2,x3,t=1,i,flag,x0;
cin >> x1 >> x2 >> x3;
x0 = max(x1,x2,x3);
for(i=2;i<=x0;i++)
{
flag = 1;
while(flag == 1)
{
flag=0;
if(x1%i==0){
x1=x1/i;
flag = 1;
}
if(x2%i==0){
x2=x2/i;
flag = 1;
}
if(x3%i==0){
x3=x3/i;
flag=1;
}
if(flag==1)
t*=i;
}
x0=max(x1,x2,x3);
}
cout << t << endl;
return 0;
}
![image-20200718103302139](https://i-blog.csdnimg.cn/blog_migrate/ea96c7cbfd3526f903dccdcd899ace9c.png)
#include <iostream>
#include <math.h>
using namespace std;
int warder(int n)
{
int a[10000];
int i,j=0,temp;
for(i=1;i<=n;i++)
{
temp=(int)sqrt(i);
if(temp*temp==i)
a[j++]=i;
}
for(i=0;i<j;i++)
cout << a[i] << " ";
return 0;
}
int main()
{
int n;
cin >> n;
warder(n);
cout << endl;
return 0;
}