結果
問題 |
No.1200 お菓子配り-3
|
ユーザー |
![]() |
提出日時 | 2020-08-28 23:20:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3,523 ms / 4,000 ms |
コード長 | 794 bytes |
コンパイル時間 | 827 ms |
コンパイル使用メモリ | 72,572 KB |
最終ジャッジ日時 | 2025-01-13 19:37:00 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:15:14: warning: format ‘%ld’ expects argument of type ‘long int*’, but argument 2 has type ‘ll*’ {aka ‘long long int*’} [-Wformat=] 15 | scanf("%ld %ld",&x,&y); | ~~^ ~~ | | | | | ll* {aka long long int*} | long int* | %lld main.cpp:15:18: warning: format ‘%ld’ expects argument of type ‘long int*’, but argument 3 has type ‘ll*’ {aka ‘long long int*’} [-Wformat=] 15 | scanf("%ld %ld",&x,&y); | ~~^ ~~ | | | | | ll* {aka long long int*} | long int* | %lld main.cpp:44:15: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘ll’ {aka ‘long long int’} [-Wformat=] 44 | printf("%ld\n",cnt); | ~~^ ~~~ | | | | | ll {aka long long int} | long int | %lld main.cpp:15:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%ld %ld",&x,&y); | ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include <iostream> #include <vector> using namespace std; int main(){ int T; cin>>T; ll x,y; while(T--){ scanf("%ld %ld",&x,&y); if(x<y) swap(x,y); ll s=x+y; ll t=x-y; vector<ll> A; for(int i=2;i*i<=s;i++){ if(s%i==0){ A.push_back(i); if(i*i!=s) A.push_back(s/i); } } ll cnt=0; for(auto c:A){ if(c==2){ if(x!=y) continue; cnt+=x-1; continue; } if(t%(c-2)!=0) continue; ll d=s/c; ll e=t/(c-2); if(d%2 != e%2) continue; if(d+e<2 || d-e<2) continue; cnt++; } printf("%ld\n",cnt); A.clear(); } return 0; }