简单枚举
与7无关的数
http://www.nowcoder.com/questionTerminal/776d401bf86d446fa783f0bef7d3c096
#include <stdio.h> int main() { int n,i,sum; while(scanf("%d",&n)!=EOF) { for(i=1,sum=0;i<=n;i++) if(i%7!=0&&i%10!=7&&i/10!=7) sum+=i*i; printf("%d\n",sum); } }
与7无关的数
http://www.nowcoder.com/questionTerminal/776d401bf86d446fa783f0bef7d3c096
#include <stdio.h> int main() { int n,i,sum; while(scanf("%d",&n)!=EOF) { for(i=1,sum=0;i<=n;i++) if(i%7!=0&&i%10!=7&&i/10!=7) sum+=i*i; printf("%d\n",sum); } }
相关推荐