日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

E:方程式

發布時間:2024/9/5 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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:方程式的全部內容,希望文章能夠幫你解決所遇到的問題。

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