結果
| 問題 |
No.653 E869120 and Lucky Numbers
|
| コンテスト | |
| ユーザー |
pin
|
| 提出日時 | 2018-02-24 13:14:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,452 bytes |
| コンパイル時間 | 669 ms |
| コンパイル使用メモリ | 83,200 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-13 07:58:02 |
| 合計ジャッジ時間 | 2,072 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:70:5: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
70 | if (ans) cout << "Yes" << endl;
| ^~
ソースコード
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
const ll MOD = 1000000007;
const ll INF = 100000;
string s;
bool judge(){
int cnt = 0, cnt2 = 0;
for (int i = 0; i < s.size(); i++){
if (s[i] == '9') return false;
if (s[i] == '8') cnt++;
if (s[i] == '1') cnt2++;
}
if (cnt > 1 || cnt2 > 1) return false;
return true;
}
bool judge2(int L){
for (int i = L; i < s.size(); i++){
int d = s[i] - '0';
if (i == s.size() - 1){
if (d < 2 || 4 < d) return false;
}
else{
if (d < 3 || 5 < d) return false;
}
}
return true;
}
int main(void){
cin >> s;
if (!judge()){
cout << "No" << endl;
return 0;
}
bool ans;
if (s[0] == '1'){
if(s.size() == 1) ans = false;
else ans = judge2(1);
}
else{
for (int i = 0; i < s.size(); i++){
int d = s[i] - '0';
if (d < 6){
if (s[i - 1] == '6') ans = false;
else ans = judge2(i);
break;
}
}
}
if (ans) cout << "Yes" << endl;
else cout << "No" << endl;
}
pin