結果

問題 No.1200 お菓子配り-3
ユーザー 沙耶花
提出日時 2020-08-28 21:55:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 755 bytes
コンパイル時間 3,638 ms
コンパイル使用メモリ 191,076 KB
最終ジャッジ日時 2025-01-13 17:17:38
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |                 scanf("%d %d",&X,&Y);
      |                 ~~~~~^~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000

int main(){
	
	int S;
	cin>>S;
	
	for(int i=0;i<S;i++){
		int X,Y;
		scanf("%d %d",&X,&Y);
		if(X<Y)swap(X,Y);
		int Z = X+Y;
		long long ans = 0;
		for(int j=1;j*j<=Z;j++){
			if(Z%j==0){
				int a = j-1;
				if(a>=2&&(X-Y)%(a-1)==0){
					int x = Z/j;
					int y = (X-Y)/(a-1);
					
					if((x+y)%2==0&&(x-y)%2==0&&(x+y)>=2&&(x-y)>=2)ans++;
				}
				
				if(a!=Z/j-1){
					a = Z/j-1;
					if(a>=2&&(X-Y)%(a-1)==0){
						int x = j;
						int y = (X-Y)/(a-1);
						
						if((x+y)%2==0&&(x-y)%2==0&&(x+y)>=2&&(x-y)>=2)ans++;
					}
				}
			}
		}
		printf("%lld\n",ans);
	}
	
	return 0;
}
0