結果

問題 No.491 10^9+1と回文
ユーザー rapurasu
提出日時 2017-03-10 23:33:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,422 bytes
コンパイル時間 1,206 ms
コンパイル使用メモリ 159,472 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-24 08:54:37
合計ジャッジ時間 3,579 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42 WA * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL N;
int main(){
        cin>>N;
        LL ans=0;
        REP(i,1<<9){
            if(i==0)continue;
            LL temp=0;
            LL temp2=1000000001;
            LL x=i;
            //bool check=false;
            while(x>0){
               if(x%2==1){
                  temp+=temp2;
               }else{
                  //check=true;
                  //break;
               }
               x/=2;
               //cout<<x<<" aaaaa"<<temp<<endl;
               temp2*=10;
            }
            //回分チェック
            bool check[10];
            REP(j,10)check[j]=false;
            x=i;
            LL count=0;
            while(x>0){
               if(x%2==1)check[count]=true;
               else check[count]=false;
               x/=2;
               count++;
            }
            bool aaa=false;
            REP(j,count){
                if(check[j]!=check[count-1-j])aaa=true;
            }
            if(aaa)continue;
            REP(j,9){
                if(N>=temp*(j+1)){
                  // cout<<i<<" "<<temp*(j+1)<<endl;
                   ans++;
                }
            }
        }
        cout<<ans<<endl;
	return(0);
}
0