結果

問題 No.1200 お菓子配り-3
ユーザー 沙耶花
提出日時 2020-08-28 21:38:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 576 bytes
コンパイル時間 3,733 ms
コンパイル使用メモリ 191,060 KB
最終ジャッジ日時 2025-01-13 16:49:00
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 4 WA * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
		
		int Z = X+Y;
		long long ans = 0;
		for(int j=2;j*j<=Z;j++){
			if(Z%j==0){
				int a = j-1;
				int c = X%a;
				int b = (X-c)/a;
				if(a*b+c==X&&a*c+b==Y)ans++;
				if(j*j!=Z){
					a = Z/j-1;
					c = X%a;
					b = (X-c)/a;
					if(a*b+c==X&&a*c+b==Y)ans++;
				}
			}
		}
		printf("%lld\n",ans);
	}
	
	return 0;
}
0