結果

問題 No.491 10^9+1と回文
ユーザー beet
提出日時 2019-01-28 16:10:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 54 ms / 1,000 ms
コード長 645 bytes
コンパイル時間 2,317 ms
コンパイル使用メモリ 201,176 KB
最終ジャッジ日時 2025-01-06 20:40:22
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 103
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  n/=Int(1e9+1);

  set<Int> ss;
  for(Int i=1;i<100000;i++){
    string s=to_string(i);
    string t(s);
    reverse(t.begin(),t.end());
    {
      Int x=stoll(s+t);
      if(x<=n) ss.emplace(x);
    }
    if(s.back()==t.front()){
      s.pop_back();
      
      Int x=stoll(s+t);
      if(x<=n) ss.emplace(x);
    }
  }
  
  cout<<ss.size()<<endl;
  return 0;
}
0