文章

43

粉丝

180

获赞

21

访问

180.5k

头像
c++
P1235 北京大学机考题
发布于2022年4月26日 17:12
阅读数 3.8k

#include <iostream>

using namespace std;

int n;

bool judge(int x)
{
	if (x % 7 == 0) return true;
	for (; x; x /= 10) if (x % 10 == 7) return true;
	return false;
}

int main()
{
	while (cin >> n)
	{
		int res = 0;
		for (int i = 1; i <= n; i ++ )
			if (!judge(i)) res += i * i;
		cout << res << endl;
	}
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发