結果
| 問題 | 
                            No.1200 お菓子配り-3
                             | 
                    
| コンテスト | |
| ユーザー | 
                             anagohirame
                         | 
                    
| 提出日時 | 2020-08-28 22:18:51 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                            (最新)
                                AC
                                 
                             
                            (最初)
                            
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 643 bytes | 
| コンパイル時間 | 2,385 ms | 
| コンパイル使用メモリ | 190,904 KB | 
| 最終ジャッジ日時 | 2025-01-13 18:07:57 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 29 WA * 2 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         int s; scanf("%d", &s);
      |                ~~~~~^~~~~~~~~~
main.cpp:7:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |                 int x, y; scanf("%d%d", &x, &y);
      |                           ~~~~~^~~~~~~~~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
	int s; scanf("%d", &s);
	for (int z = 0; z < s; ++z) {
		int x, y; scanf("%d%d", &x, &y);
		if (x == y) {
			printf("%d\n", x-1);
			continue;
		}
		if (x < y) swap(x, y);
		int ans = 0;
		for (int i = 1; i*i <= x-y; ++i) {
			if ((x-y) % i != 0) continue;
			if ((x+y) % (i+2) == 0) {
				int p = (x-y) / i; int q = (x+y) / (i+2);
				if (p < q and p%2 == q%2) ans++;
			}
			if (i*i == x-y) continue;
			int j = (x-y)/i;
			if ((x+y) % (j+2) == 0) {
				int p = (x-y) / j; int q = (x+y) / (j+2);
				if (p < q and p%2 == q%2) ans++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}
            
            
            
        
            
anagohirame