제출 #1120525

#제출 시각아이디문제언어결과실행 시간메모리
1120525vjudge1Palindrome-Free Numbers (BOI13_numbers)C++17
28.33 / 100
1101 ms508 KiB
#include <bits/stdc++.h>

using namespace std;

#define int long long

bool check_palindrome(string s)
{
    for(int i=0;i<s.size()/2;i++)
        if(s[i]!=s[s.size()-i-1])
            return false;
    
    return true;
}

bool check(string s)
{
    for(int i=0;i<s.size();i++)
    {
        for(int j=i+1;j<s.size();j++)
        {
            string cur="";
            
            for(int k=i;k<=j;k++)
                cur+=s[k];
            
            if(check_palindrome(cur))
                return false;
        }
    }
    
    return true;
}

void solve()
{
    int a,b,res=0;
    
    scanf("%ld%ld",&a,&b);
    
    for(int i=a;i<=b;i++)
    {
        string s=to_string(i);
        
        if(check(s))
            res++;
    }
    
    printf("%ld",res);
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
}

컴파일 시 표준 에러 (stderr) 메시지

numbers.cpp: In function 'bool check_palindrome(std::string)':
numbers.cpp:9:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0;i<s.size()/2;i++)
      |                 ~^~~~~~~~~~~
numbers.cpp: In function 'bool check(std::string)':
numbers.cpp:18:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int i=0;i<s.size();i++)
      |                 ~^~~~~~~~~
numbers.cpp:20:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         for(int j=i+1;j<s.size();j++)
      |                       ~^~~~~~~~~
numbers.cpp: In function 'void solve()':
numbers.cpp:39:14: warning: format '%ld' expects argument of type 'long int*', but argument 2 has type 'long long int*' [-Wformat=]
   39 |     scanf("%ld%ld",&a,&b);
      |            ~~^     ~~
      |              |     |
      |              |     long long int*
      |              long int*
      |            %lld
numbers.cpp:39:17: warning: format '%ld' expects argument of type 'long int*', but argument 3 has type 'long long int*' [-Wformat=]
   39 |     scanf("%ld%ld",&a,&b);
      |               ~~^     ~~
      |                 |     |
      |                 |     long long int*
      |                 long int*
      |               %lld
numbers.cpp:49:15: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'long long int' [-Wformat=]
   49 |     printf("%ld",res);
      |             ~~^  ~~~
      |               |  |
      |               |  long long int
      |               long int
      |             %lld
numbers.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     scanf("%ld%ld",&a,&b);
      |     ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...