标签:ble ++ rip oid printf problem tom 暴力 namespace
#include<bits/stdc++.h> using namespace std; //input by bxd #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define RI(n) scanf("%d",&(n)) #define RII(n,m) scanf("%d%d",&n,&m) #define RIII(n,m,k) scanf("%d%d%d",&n,&m,&k) #define RS(s) scanf("%s",s); #define LL long long #define REP(i,N) for(int i=0;i<(N);i++) #define CLR(A,v) memset(A,v,sizeof A) ////////////////////////////////// #define N 150000+5 int ans[N]; bool judge(int x) { while(x!=1&&x!=4) { int sum=0; while(x) { sum+=(x%10)*(x%10); x/=10; } x=sum; } return x==1; } void get(void) { int cnt=1; ans[1]=1; int i=2; while(cnt<=150000) { if(judge(i)) ans[++cnt]=i; i++; } } int main() { get(); int q; RI(q); while(q--) { int x; RI(x); printf("%d\n",ans[x]); } }
标签:ble ++ rip oid printf problem tom 暴力 namespace
原文地址:https://www.cnblogs.com/bxd123/p/10560285.html