結果

問題 No.186 中華風 (Easy)
ユーザー itezpaceitezpace
提出日時 2016-08-14 07:19:43
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,108 bytes
コンパイル時間 599 ms
コンパイル使用メモリ 55,008 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-25 06:30:55
合計ジャッジ時間 3,953 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,624 KB
testcase_01 TLE -
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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:69:12: warning: ‘p’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   69 |     } else if(p==2){
      |            ^~
main.cpp:10:9: warning: ‘y’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   10 |   int x,y,p;
      |         ^
main.cpp:10:7: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   10 |   int x,y,p;
      |       ^

ソースコード

diff #

#include <iostream>
#include <climits>
using namespace std;
typedef long long ll;
int main(){
  int x1,y1,x2,y2,x3,y3;
  cin>>x1>>y1;
  cin>>x2>>y2;
  cin>>x3>>y3;
  int x,y,p;
  if(y1<=y2){
    if(y1<=y3){
      y=y1;
      x=x1;
      p=1;
    }
  } else {
    if(y2<=y3){
      y=y2;
      x=x2;
      p=2;
    } else {
      y=y3;
      x=x3;
      p=3;
    }
  }
  int o,e;
  o=0;
  e=0;
  if(y1%2==0){
    if(x1%2==0){
      e++;
    } else {
      o++;
    }
  }
  if(y2%2==0){
    if(x2%2==0){
      e++;
    } else {
      o++;
    }
  }
  if(y3%2==0){
    if(x3%2==0){
      e++;
    } else {
      o++;
    }
  }
  if(o>0 && e>0){
    cout<<-1<<endl;
    return 0;
  }
  ll i,z;
  i=0;
  while(1){
    if(i==LLONG_MAX){
      cout<<-1<<endl;
      break;
    }
    z=y*i+x;
    if(p==1){
      if(z%y2==x2 && z%y3==x3){
        cout<<z<<endl;
        break;
      }
    } else if(p==2){
      if(z%y1==x1 && z%y3==x3){
        cout<<z<<endl;
        break;
      }
    } else if(p==3){
      if(z%y1==x1 && z%y2==x2){
        cout<<z<<endl;
        break;
      }
    }
    i++;
  }
  return 0;
}
0