51Nod 1082 | 模拟

Input示例
5
4
5
6
7
8
Output示例
30
55
91
91
155

模拟
#include "bits/stdc++.h"
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f3f
#define PI acos(-1)
#define N 1000010
#define MOD 10
using namespace std;  
LL sum[N]={0};  
bool isconect(int a)  
{  
    if(a%7==0){  
        return true;  
    }  
    while(a!=0){  
        if(a%10==7){  
            return true;  
        }  
        a=a/10;  
    }  
    return false;  
}  
int main()  
{  
    int T,n;  
    cin>>T;  
    for(LL i=1;i<=N;i++){  
        sum[i]=sum[i-1];  
        if(!isconect(i)){  
            sum[i]+=i*i;  
        }  
    }  
    while(T--){  
        cin>>n;  
        cout<<sum[n]<<endl;  
    }  
    return 0;  
}  
原文地址:https://www.cnblogs.com/kimsimple/p/7461114.html