結果
| 問題 | No.186 中華風 (Easy) |
| コンテスト | |
| ユーザー |
184
|
| 提出日時 | 2015-04-20 00:20:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 773 bytes |
| 記録 | |
| コンパイル時間 | 387 ms |
| コンパイル使用メモリ | 24,704 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 15:52:31 |
| 合計ジャッジ時間 | 1,522 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 WA * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf("%d%d",&a,&b);a1=a,b1=b;
| ~~~~~^~~~~~~~~~~~~~
main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%d%d",&a,&b);a2=a,b2=b;
| ~~~~~^~~~~~~~~~~~~~
main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf("%d%d",&a,&b);a3=a,b3=b;
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
/*
x=c%y
x+ay=c;
x+ay=c;
c-ay=x;
c-ay=x;
*/
int main(){
//int n;scanf("%d",&n);
long long a1,a2,a3,b1,b2,b3,c;
int a,b;
scanf("%d%d",&a,&b);a1=a,b1=b;
scanf("%d%d",&a,&b);a2=a,b2=b;
scanf("%d%d",&a,&b);a3=a,b3=b;
long long y1=b1*b2,x1=a1*b2,y2=b1*b2,x2=a2*b1;
long long c1=(a2-a1),c2=(a3-a2);
long long ya=b1,yb=b2;
long long y11;while(y11=yb%ya){yb=ya,ya=y11;}
y11=ya;
ya=b2,yb=b3;
long long y22;while(y22=yb%ya){yb=ya,ya=y22;}
y22=ya;
if(c1%y11||c2%y22){
printf("-1\n");return 0;
}
for(long long xx=0;xx<=y11;xx+=a1){
if((c1-xx)%y2==0){
long long yy=(c1-xx)/y2;
if(yy<=0){
printf("-1\n");
return 0;
}
printf("%lld\n",x1+xx);
}
}
return 0;
}
184