题目链接
题解
一道非常有趣的数学题?
n1、n2、n3表示的是7进制下的三个数字和对应的9进制下的三个数字.
因为题目要求.7进制和9进制下和三个数字要相对应.
而且确定是三位数了,那问题就不大.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> using namespace std ; template<class T>void read(T &x){ x=0;int f=0;char ch=getchar(); while(ch<'0'||ch>'9'){f|=(ch=='-');ch=getchar();} while(ch<='9'&&ch>='0'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();} x=f?-x:x; return ; } int main(){ int n1,n2,n3; for(int i=81;i<=248;++i) if((n1=i/49)==i%9&&(n2=i/81)==i%7&&(n3=i%49/7)==i%81/9) printf("%d\n%d%d%d\n%d%d%d",i,n1,n3,n2,n2,n3,n1); return 0; } |
By:Wahacer
2017.11.19
17:46