結果

問題 No.293 4>7の世界
ユーザー itezpaceitezpace
提出日時 2016-05-13 19:02:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 995 bytes
コンパイル時間 1,527 ms
コンパイル使用メモリ 159,600 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 16:27:45
合計ジャッジ時間 2,450 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define REP(i, a, b) for(int i=a;i<b;++i)

#define MAX 200000001

int main(){
  string A, B;
  ll a, b;
  cin >> A >> B;
  int aff=0;
  int bff=0;
  int afs=0;
  int bfs=0;
  ll apf=MAX;
  ll bpf=MAX;
  ll aps=MAX;
  ll bps=MAX;
  REP(i,0,A.size()){
    if(A[i]=='4') aff=1, apf=i;
    if(A[i]=='7') afs=1, aps=i;
  }
  REP(j,0,B.size()){
    if(B[j]=='4') bff=1, bpf=j;
    if(B[j]=='7') bfs=1, bps=j;
  }

  if(A.size() == B.size()){
    if(aff==1 || bff==1){
      if(afs==1 || bfs==1){
        if(apf<bps){ a = stoi(A); cout << a << endl; return 0;}
        if(aps>bpf) { b = stoi(B); cout << b << endl; return 0;}
        if(apf<aps){
          if(apf==bps) { a = stoi(A); cout << a << endl; return 0;}
        } else if(apf>aps){
          if(aps==bpf) { b = stoi(B); cout << b << endl; return 0;}
        }
      }
    }
  }
  a = stoi(A);
  b = stoi(B);
  cout << max(a,b) << endl;
  return 0;
}
0