summaryrefslogtreecommitdiff
path: root/1.3/dualpal.c
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-04-16 19:06:32 +0800
committerIru Cai <mytbk920423@gmail.com>2018-04-16 19:06:32 +0800
commitad4e2420e822b8a115aac6124307b89447578782 (patch)
tree6f4db875081597e2e64dd4221a97bbff25503dcc /1.3/dualpal.c
parenta7721767628a51b752ad3a96eb334734241dcd8b (diff)
downloadusaco-ad4e2420e822b8a115aac6124307b89447578782.tar.xz
1.2~1.5
Diffstat (limited to '1.3/dualpal.c')
-rw-r--r--1.3/dualpal.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/1.3/dualpal.c b/1.3/dualpal.c
new file mode 100644
index 0000000..caa516e
--- /dev/null
+++ b/1.3/dualpal.c
@@ -0,0 +1,50 @@
+/*
+ID: mytbk921
+LANG: C
+TASK: dualpal
+*/
+
+#include <stdio.h>
+
+int dualpal(int a) //check if a is dualpal
+{
+ int chk[32];
+ int l,base,i;
+ int count=0;
+ for (base=10;base>=2;base--){
+ l=0;
+ for (chk[0]=a;chk[l];++l){
+ chk[l+1]=chk[l]/base; //when chk[l+1]=0,the conversion is over
+ chk[l]%=base;
+ }
+ for (i=0;i<l/2;i++){
+ if (chk[i]!=chk[l-1-i])
+ break;
+ }
+ if (i>=l/2)
+ ++count;
+ if (count==2)
+ return 1;
+ }
+ return 0;
+}
+
+int main()
+{
+ int n,s;
+ FILE *fin=fopen("dualpal.in","r");
+ FILE *fout=fopen("dualpal.out","w");
+ fscanf(fin,"%d%d",&n,&s);
+ fclose(fin);
+
+ while (n){
+ ++s;
+ if (dualpal(s)){
+ fprintf(fout,"%d\n",s);
+ --n;
+ }
+ }
+
+ return 0;
+}
+