与7无关的数
题目描述
Attention:C++标准中禁止用main函数递归,正式比赛请勿使用。能使用是因为C语言标准较为宽松,一般能编译C++的编译器都能兼容C,但评测环境下不保证不会出现奇怪的错误。
#include<iostream>
#include<cstdlib>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
ll x,p = 1,ans;
bool b = true;
int main()
{
ios::sync_with_stdio(false);
if(b)
{
cin >> x;
b ^= 1;
}
if(p == x + 1)
{
cout << ans << endl;
exit(0);
}
ll t = p;
bool flag = true;
while(t)//将它的每一位数都判断一下
{
if(t % 10 == 7)
{
flag = false;
break;
}
t /= 10;
}
if(flag&&p % 7) ans = ans + p * p;//原数也要判断
++p;
main();
return 0;
}