#include <math.h>
int main()
{
int x,y,n,m,f
scanf("%d",&n)
m = sqrt(n/2.0)
f = 1
for(x=0x<=mx++)
{
y = sqrt(n - x*x)
if(x*x + y*y == n)
{
printf("%d %d\n",x,y)
f = 0
}
}
if(f)
printf("No Solution")
return 0
}
请采纳。
#include<stdio.h>#include<string.h>
#include<stdlib.h>
int main()
{
int N,K,m,i,t,a[20]={0}
scanf("%d %d",&N,&K)
for(i=0i<K+1i++)
{
scanf("%d",&a[i])
}
m=N
m=m-a[0]
i=1
t=0
while(1)
{
if(m<0){printf("No Solution")break}
if(m-a[i]<0){t++m=N-a[i]}
else m=m-a[i]
i++
if(m<0){printf("No Solution\n")break}
if(i==K+1){printf("%d\n",t)break}
}
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)