結果

問題 No.491 10^9+1と回文
ユーザー goodbaton
提出日時 2017-05-30 23:04:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,146 bytes
コンパイル時間 707 ms
コンパイル使用メモリ 86,488 KB
実行使用メモリ 8,832 KB
最終ジャッジ日時 2024-09-21 19:24:56
合計ジャッジ時間 4,323 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 77 WA * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:33:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |   scanf("%lld",&n);
      |   ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  ll n;
  set<ll> mm;
  scanf("%lld",&n);

  int m = n/1000000000;

  int ans = 0;
  
  for(int i=0;i<m;i++){
    int p = i;

    char s1[20],s1_r[20],s2[20];

    sprintf(s1_r,"%d",p);
    reverse(s1_r,s1_r+strlen(s1_r));
    
    sprintf(s1,"%d%s",p,s1_r);
    sprintf(s2,"%d%s",p/10,s1_r);

    ll q1 = atoll(s1);    
    ll q2 = atoll(s2);

    //debug(q1);
    //debug(q2);
    
    if(q1 <= m && mm.find(q1) == mm.end()){
      mm.insert(q1);
      ans++;
    }

    if(q2 <= m && mm.find(q2) == mm.end()){
      mm.insert(q2);
      ans++;
    }

    if(q1 >= 10000000000LL) break;
  }
  
  cout << ans-1 << endl;
  
  return 0;
}
0