P2089 烤鸡
#include <bits/stdc++.h>
using namespace std;
int main()
{
int x;
int res=0;
cin>>x;
for(int a=1; a<=3; a++)
for(int b=1; b<=3; b++)
for(int c=1; c<=3; c++)
for(int k=1; k<=3; k++)
for(int d=1; d<=3; d++)
for(int e=1; e<=3; e++)
for(int f=1; f<=3; f++)
for(int g=1; g<=3; g++)
for(int h=1; h<=3; h++)
for(int i=1; i<=3; i++)
{
if(a+b+c+d+e+f+g+h+i+k==x)
res++;
}
cout<<res<<endl;
for(int a=1; a<=3; a++)
for(int b=1; b<=3; b++)
for(int c=1; c<=3; c++)
for(int k=1; k<=3; k++)
for(int d=1; d<=3; d++)
for(int e=1; e<=3; e++)
/ for(int f=1; f<=3; f++)
for(int g=1; g<=3; g++)
for(int h=1; h<=3; h++)
for(int i=1; i<=3; i++)
{
if(a+b+c+d+e+f+g+h+i+k==x)
printf("%d %d %d %d %d %d %d %d %d %d\n",a,b,c,k,d,e,f,g,h,i);
}
return 0;
}
P1618 三连击(升级版)
#include <bits/stdc++.h>
using namespace std;
struct res
{
int num1,num2,num3;
} x[10000];
int main()
{
int a,b,c;
cin>>a>>b>>c;
int j,k;
int t=0;
int y[12];
for(int i=100; i<=999; i++)
{
j=i*b/a;
k=i*c/a;
y[0]=i%10;
y[1]=(i/10)%10;
y[2]=i/100;
y[3]=j%10;
y[4]=(j/10)%10;
y[5]=j/100;
y[6]=k%10;
y[7]=(k/10)%10;
y[8]=k/100;
int f=0;
for(int a=0; a<=8; a++)
for(int b=a+1; b<=8; b++)
if((y[a]==y[b])||y[a]==0||y[b]==0)
{
f=1;
break;
}
if(j>=100&&j<=999&&k>=100&&k<=999&&f==0)
{
x[t].num1=i;
x[t].num2=j;
x[t].num3=k;
t++;
}
}
if(t!=0)
{
for(int i=0; i<t; i++)
{
printf("%d %d %d\n",x[i].num1,x[i].num2,x[i].num3);
}
}
else
printf("No!!!\n");
return 0;
}
P1426 小鱼会有危险吗
#include <bits/stdc++.h>
using namespace std;
int main()
{
double x,s;
cin>>s>>x;
double v=7.0;
double d=s-x;
if(x==0)
printf("n");
else
{
while(d>=0)
{
d=d-v;
v=v*0.98;
}
if(d+2*x<=v*0.98)
printf("n");
else
printf("y");
}
return 0;
}
P1014 Cantor表
#include <bits/stdc++.h>
using namespace std;
int main()
{
int x;
scanf("%d",&x);
int i;
for(i=1;; i++)
{
x=x-i;
if(x<=0)
break;
}
x=x+i;
if(i%2==0)
printf("%d/%d",x,i-x+1);
else
printf("%d/%d",i-x+1,x);
return 0;
}
P1307 数字反转
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long int x;
cin>>x;
if(x<0)
{
x=-x;
printf("-");
}
int a[12]= {0};
int t=0;
while(x!=0)
{
a[t]=x%10;
x=x/10;
t++;
}
int f=0;
for(int i=0; i<t; i++)
if(a[i]!=0)
{
f=i;
break;
}
for(int i=f; i<t; i++)
cout<<a[i];
return 0;
}