题解 | #与7无关的数#
与7无关的数
https://www.nowcoder.com/practice/776d401bf86d446fa783f0bef7d3c096
#include <iostream>
#include <cstdio>
using namespace std;
int n;
int sum=0;
int wg=0;
int a[100]={0};
double pfh(int *a)
{
double h=0;
for(int j=1;j<=wg;j++)
{
h+=a[j]*a[j];
}
return h;
}
int main() {
cin>>n;
for(int i=1;i<=n;i++)
{
if(i%7==0||i%10==7||i%100/10==7||i/100==7)
{
sum++;
}
else
{
wg++;
a[wg]=i;
}
}
cout<<pfh(a);
}
// 没啥好说的
查看3道真题和解析
