题目地址:http://t.cn/E9lOOZQ
代码如下:
#include<iostream>
using namespace std;
//是否与7有关
bool about7(int i)
{
if (i % 7 == 0)
return true;
while (i > 0)
{
if (i % 10 == 7)
return true;
i /= 10;
}
return false;
}
int main()
{
int n = 0;
cin >> n;
int total = 0;
for (int i = 0; i <= n; i++)
{
if (!about7(i))
total += i * i;
}
cout << total << endl;
return 0;
}