- 考级202012-2:计算算式的值
特殊求和
- 2023-7-27 13:56:21 @
#include <bits/stdc++.h>
using namespace std;
bool m(int x)
{
int a=x;
while(a>0)
{
if(a%10==7)
{
return true;
}
a=a/10;
}
return false;
}
int main()
{
int N;
int sum=0;
cin>>N;
for(int i=1;i<=N;i++)
{
if(i%7==0||m(i)==true)
{
sum+=i;
}
}
cout<<sum;
return 0;
}
0 comments
No comments so far...
Information
- ID
- 576
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 90
- Accepted
- 34
- Uploaded By