9 solutions
-
2
#include <bits/stdc++.h> using namespace std; int n; bool check(int x){//自定义函数 if(x%7==0) return false; while(x){ int k=x%10; if(k==7) return false; x/=10; } return true; } int main(){ cin>>n; long long sum=0; for(int i=1;i<=n;i++) if(check(i)==true) sum+=i*i;//这里也可以用pow函数 cout<<sum<<endl; return 0;//华丽结尾 } //加油吧年轻人
-
1
#include <bits/stdc++.h> using namespace std; bool is7(int n); int main(int argc, char **argv){ int n;long long s = 0; cin >> n; for (int i = 1;i <= n;i++){ if (i % 7 != 0 && is7(i)){ s += i * i; } } cout << s; return 0; } bool is7(int n){ while(n > 0){ if(n % 10 == 7){ return false; } n /= 10; } return true; }
- 1
Information
- ID
- 585
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 4
- Tags
- # Submissions
- 168
- Accepted
- 77
- Uploaded By