【 OJ 】 HDOJ1017 18年10月30日19:57 [ 16 ]
阿新 • • 發佈:2018-12-18
ummm,這題目好煩人....看半天根本讀不懂.....然後發現....有點水....
然後竟然沒有AC
# include<iostream> using namespace std; void out(int count) { static int n = 1; cout << "Case " << n << ": " << count << endl; n++; } int main(void) { //integers (a,b) 暗示整形 // 0 < a < b < n 暗示 a 外圍0-n,b=a+1 // 判定式 (a^2+b^2 +m)/(ab) is an integer. int N; int n, m;// that 0 < n <= 100. int a, b; int count = 0; cin >> N; for (int index = 0; index < N; ++index) { cin >> n >> m; while (n || m) { for (a = 1; a < n; ++a) { for (b = a + 1; b < n; ++b) { if (!((a*a + b*b + m) % (a*b))) count++; } } out(count); count = 0;//count 清零 cin >> n >> m; } if (index != N - 1) cout << endl; } system("pause"); return 0; }