#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
",i,j,k);
return 0;
}
#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;
}
#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;
}
#include <iostream>
#include <string.h>
using namespace std;
//パターン文字列tのnext関数の値を求め、配列nextに格納する。
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)
//パターン文字列tのnext関数を使って、メイン文字列sのposth文字の後のtの位置を見つける。
{
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;
char s,t;
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;
}
#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;
}
#include <iostream>
#include <math.h>
using namespace std;
int warder(int n)
{
int a;
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;
}