(HDU)1017 --A Mathematical Curiosity(數學好奇心)

來源:互聯網
上載者:User

標籤:scan   src   turn   isp   cas   編號   多個   out   技術分享   

描述給定兩個整數n和m,計數整數對(a,b)的數目,使得0 <a <b <n,並且(a ^ 2 + b ^ 2 + m)/(ab)是一個整數。這個問題包含多個測試案例!輸入的第一行是整數N,然後是空白行,後跟N個輸入塊。 每個輸入塊採用問題說明中指示的格式。 輸入塊之間有空行。輸出格式由N個輸出塊組成。 輸出塊之間有一個空行。輸入您將在輸入中獲得多個範例。 每個情況由包含整數n和m的行指定。 輸入結束由n = m = 0的情況表示。您可以假設0 <n <= 100。輸出對於每種情況,輸出範例編號以及滿足給定屬性的對數(a,b)。 在一行上輸出每種情況的答案,格式如下所示。樣品輸入110 120 330 40 0樣本輸出Case 1: 2Case 2: 4Case 3: 5
題目

找出滿足要求的數對,這題容易WA和PE,都是格式的原因。

這題其實特別水,n的範圍很小,忽略輸入的空行也可以AC...

 

 1 #include <iostream> 2 #include <cstdio> 3  4 using namespace std; 5  6 int main() 7 { 8  9     int N;10     int n,m;11     scanf("%d",&N);12     while(N--)13     {14         int num=1;15         while(~scanf("%d%d",&n,&m) &&(n||m) )16         {17             int sum=0;18             int i,j;19             for(i=1;i<n;i++)20             {21                 for(j=i+1;j<n;j++)22                 {23                     if((i*i+j*j+m)%(i*j) == 0)24                         sum++;25                 }26             }27             printf("Case %d: %d\n",num++,sum);28         }29         if(N)30             printf("\n");31     }32     return 0;33 }
代碼

(HDU)1017 --A Mathematical Curiosity(數學好奇心)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.