/**//* PROG: dualpal LANG: C++ */ #include <iostream> #include <fstream> #include <string> #include <cmath> usingnamespace std; ifstream fin("dualpal.in"); ofstream fout("dualpal.out"); int n,s; inline bool hui (int k,int b) ...{ int a[32],l=0; while( k>0) ...{ l++; a[l]=k%b; k/=b; } int i=1; while( a[i]==a[l]) i++,l--; if( i>=l) returntrue; elsereturnfalse ; } inline bool check(int k) ...{ int p=0; for(int i=2;p<2&&i<=10;i++) if( hui( k , i) ) p++; return (p==2); } int main() ...{ fin>>n>>s; for(int i=s+1;n>0;i++) if( check(i) ) fout<<i<<endl,n--; return0; }
Compiling... Compile: OK Executing... Test 1: TEST OK [0 secs] Test 2: TEST OK [0.004 secs] Test 3: TEST OK [0.012 secs] Test 4: TEST OK [0.004 secs] Test 5: TEST OK [0 secs] Test 6: TEST OK [0.004 secs] Test 7: TEST OK [0.004 secs] All tests OK. YOUR PROGRAM ('dualpal') WORKED FIRST TIME! That's fantastic -- and a rare thing. Please accept these special automated congratulations.