立方尾不变
有些数字的立方的末尾正好是该数字本身。
比如:1,4,5,6,9,24,25,....
请你计算一下,在10000以内的数字中(指该数字,并非它立方后的数值),符合这个特征的正整数一共有多少个。
请提交该整数,不要填写任何多余的内容。
#include <iostream> #include <string> using namespace std; int main() { long s; for(int i=1;i<10000;i++) { s = i*i*i; if(i>=1&&i<10) { if(s%10 == i) { cout<<i<<" "<<s<<endl; } } else if(i>=10&&i<100) { if(s%100 == i) { cout<<i<<" "<<s<<endl; } } else if(i>=100&&i<1000) { if(s%1000 == i) { cout<<i<<" "<<s<<endl; } } else { if(s%10000 == i) { cout<<i<<" "<<s<<endl; } } } return 0; }