Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
42107 jiabokai 九进制回文数 C++ 通过 1 MS 256 KB 555 2024-02-24 10:29:11

Tests(1/1):


#include<bits/stdc++.h> using namespace std; bool pd(int x,int k){ while(x){ if(x%k%2==0){ return false; } x/=k; } return true; } int t(int n,int k){ int pos=1; int a=0; while(n){ a=a+n%k*pos; pos*=10; n/=k; } return a; } bool reverse(int n){ int h=0; int m=n; while(n){ h=h*10+n%10; n/=10; } if(h==m){ return true; }else return false; } int main() { int n,m,cnt=0; cin>>n>>m; for(int i=n;i<=m;i++){ if(pd(i,9)&&reverse(t(i,9))){ cnt++; } } cout<<cnt; return 0; }


测评信息: