結果

問題 No.1200 お菓子配り-3
ユーザー Y17Y17
提出日時 2020-08-28 22:40:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 809 bytes
コンパイル時間 1,624 ms
コンパイル使用メモリ 164,608 KB
実行使用メモリ 16,960 KB
最終ジャッジ日時 2024-04-26 23:44:46
合計ジャッジ時間 12,141 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'long long int yta()':
main.cpp:46:1: warning: no return statement in function returning non-void [-Wreturn-type]
   46 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void fast_input_init(){
	ios::sync_with_stdio(false);
	cin.tie(0);
}

int yta();

signed main(){
	fast_input_init();
	int s;
	cin >> s;
	while(s--) yta();

	return 0;
}

int x, y;
inline int valid(int a){
	if(a == 0) return 0;
	int sita = a*a-1;
	int ue = a*x-y;
	if(sita == 0 || ue <= 0 || ue%sita != 0) return 0;
	int b = ue/sita; 
	if(x-a*b <= 0) return 0;
	return 1;
}

int yta(){
	cin >> x >> y;

	int ans = 0;
	for(int i = 1;i*i <= x+y;i++){
		if((x+y)%i == 0){
			ans += valid(i-1);
			if(i*i < x+y) ans += valid((x+y)/i-1);
		}
	}
	cout << ans << endl;
}
0