제출 #1191942

#제출 시각아이디문제언어결과실행 시간메모리
1191942Yusif_NazarliPalindrome-Free Numbers (BOI13_numbers)C++20
36.67 / 100
1096 ms484 KiB
// author: Yusif_Nazarli

#pragma GCC optimize("O3")
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"

#define Mor_Te ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gcd __gcd
#define intt long long
#define pb push_back
#define emb emplace_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define F first
#define S second
#define pii pair<intt ,intt>
#define reset_map(m) for(auto &[k , v] : m) v = 0;


using namespace std;
using namespace __gnu_pbds;

template <typename T>
using indexed_set = tree<T , null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update>;

const intt sz = 1e5 + 5;
const intt INF = 1e18;

bool isPalindrome(const string &s){
    int l = 0, r = s.size() - 1;
    while(l < r){
        if(s[l] != s[r]) return false;
        l++;
        r--;
    }
    return true;
}


bool ispolindromfree(string s){
    for(intt i = 0; i < s.size(); i++){
        string res = "";
        for(intt j = i; j < s.size(); j++){
            res += s[j];
            if(res.size() > 1 && isPalindrome(res)){
                return false;
            }
        }
    }
    return true;
}

void Yusiff(){
    intt a , b; cin >> a >> b;
    intt cnt = 0;
    for(intt i = a; i <= b; i++){
        string s = to_string(i);
        if(ispolindromfree(s)) cnt++;
    }
    cout << cnt << '\n';
}

signed main(){
    int t = 1;
    //cin >> t;
    for(intt i = 1; i <= t; i++){
      //  cout << "Case " << i << ": ";
        Yusiff();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...