日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

E:方程式

發布時間:2024/9/5 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 E:方程式 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目:

Description

Consider equations having the following form: a*x1*x1 + b*x2*x2 + c*x3*x3 + d*x4*x4 = 0
a, b, c, d are integers from the interval [-50,50] and any of them cannot be 0.
It is consider a solution a system ( x1,x2,x3,x4 ) that verifies the equation, xi is an integer from [-100,100] and xi != 0, any i ∈{1,2,3,4}.
Determine how many solutions satisfy the given equation.

Input

The input consists of several test cases. Each test case consists of a single line containing the 4 coefficients a, b, c, d, separated by one or more blanks.

Output

or each test case, output a single line containing the number of the solutions.

Sample Input

1 2 3 -4 1 1 1 1

Sample Output

39088 0

代碼:

?

#include <stdio.h>
#include <stdlib.h>
int a[10000],b[10000];
int cmp ( const void *a , const void *b )
{
return *(int *)a - *(int *)b;
}
int main()
{
??? int x[4],i,j,k,count,t;
??? while(scanf("%d%d%d%d",&x[0],&x[1],&x[2],&x[3])!=EOF)
??? {
?????????????? for(k=0,i=1;i<=100;i++)
?????????????? {
????????????????????????????????????????? for(j=1;j<=100;j++)
????????????????????????????????????????? {
???????????????????????????????????????????????? a[k]=x[0]*i*i+x[1]*j*j;
???????????????????????????????????????????????? b[k]=-1*(x[2]*i*i+x[3]*j*j);
???????????????????????????????????????????????? k++;
????????????????????????????????????????? }???????
?????????????? }
?????????????? qsort(a,10000,sizeof(a[0]),cmp);//快排
?????????????? qsort(b,10000,sizeof(b[0]),cmp);
?????????????? count=i=j=0;
?????????????? while(i<k && j<k)
?????????????? {
???????????????????????? if(a[i]<b[j]) i++;
???????????????????????? else if(a[i]>b[j]) j++;
???????????????????????? else
???????????????????????? {
???????????????????????????? t=j+1;
???????????????????????????? count++;
???????????????????????????? while(t<k && a[i]==b[t]) {count++;t++;}
???????????????????????????? i++;
???????????????????????? }
?????????????? }
?????????????? printf("%d\n",count*16);
??? }
??? return 0;
}

首發:http://www.iwebtrados.com.cn/post/363.html

轉載于:https://www.cnblogs.com/webtrados/archive/2010/04/06/1705616.html

總結

以上是生活随笔為你收集整理的E:方程式的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。